-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
134 lines (107 loc) · 4.88 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
#Project name
project(Neon
VERSION 0.3.3
LANGUAGES CXX C CUDA)
#Default build type is Release if no build type is passed by the user
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif ()
if (WIN32)
set(LIBIGL_USE_STATIC_LIBRARY "ON" CACHE BOOL "Use Libigl as a static library")
set(NEON_USE_POLYSCOPE "ON" CACHE BOOL "Enable Ployscope for visualization")
endif()
if(${NEON_USE_POLYSCOPE})
message(STATUS "Polyscope is enabled")
else()
message(STATUS "Polyscope is disabled")
endif()
# Manage between building Neon as shared or static library
include("${PROJECT_SOURCE_DIR}/cmake/ManageLibraryType.cmake")
# Manage unit testing compilation following directives from BUILD_NEON_TESTING
include("${PROJECT_SOURCE_DIR}/cmake/ManageUnitTests.cmake")
# Manage CUDA compute capabilities by setting CMAKE_CUDA_ARCHITECTURES
include("${PROJECT_SOURCE_DIR}/cmake/ManageTargetCUDACompute.cmake")
# Toggle NVTX ranges. Enabled by default on linux. To enable use "-DNEON_USE_NVTX=ON"
include("${PROJECT_SOURCE_DIR}/cmake/Nvtx.cmake")
# Direct all output to /bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# Enable IDE folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Fetching external git repositories:
# - spdlog, rapidjson, GoogleTest (only if tests are enabled)
include("${PROJECT_SOURCE_DIR}/cmake/LoadingExternalGitRepositories.cmake")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Definition of the target interface NeonDeveloperLib
add_library(NeonDeveloperLib INTERFACE)
target_compile_features(NeonDeveloperLib INTERFACE cxx_std_17)
include("${PROJECT_SOURCE_DIR}/cmake/ManageCompilationFlags.cmake")
# Get and store git sha1 https://stackoverflow.com/a/4318642/1608232
include("${PROJECT_SOURCE_DIR}/cmake/ManageGitShaInformation.cmake")
target_compile_options(NeonDeveloperLib INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${NeonCXXFlags}>
$<$<COMPILE_LANGUAGE:CUDA>:${NeonCUDAFlags}>
)
target_include_directories(NeonDeveloperLib INTERFACE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
if (${BUILD_NEON_SHARED_LIBS})
set_property(TARGET NeonDeveloperLib PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET NeonDeveloperLib PROPERTY CUDA_SEPARABLE_COMPILATION ON)
endif ()
if (${NEON_USE_NVTX})
target_compile_definitions(NeonDeveloperLib INTERFACE NEON_USE_NVTX)
endif ()
#OpenMP
find_package(OpenMP)
if (NOT OpenMP_CXX_FOUND)
message(FATAL_ERROR "Neon could not find OpenMP")
endif ()
target_link_libraries(NeonDeveloperLib INTERFACE OpenMP::OpenMP_CXX)
if(${NEON_USE_POLYSCOPE})
target_compile_definitions(NeonDeveloperLib INTERFACE NEON_USE_POLYSCOPE)
endif()
#target_link_libraries(libNeonXXX INTERFACE $<BUILD_INTERFACE:NeonDeveloperLib>)
add_subdirectory("libNeonCore")
add_subdirectory("libNeonSys")
add_subdirectory("libNeonSet")
add_subdirectory("libNeonDomain")
add_subdirectory("libNeonSkeleton")
#add_subdirectory("libNeonSolver")
add_subdirectory("tutorials")
add_subdirectory("apps")
add_subdirectory("benchmarks")
#-------------------------------------------------------------------#
# Configuration summary
#-------------------------------------------------------------------#
message("//===================================================")
message("|| ${PROJECT_NAME} build configuration:")
message("|| ${PROJECT_NAME} version : ${PROJECT_VERSION}")
message("||===================================================")
message("|| CMake version : ${CMAKE_VERSION}")
if (NOT CMAKE_BUILD_TYPE)
message("|| CMake build type : NOT SET !")
else ()
message("|| CMake build type : ${CMAKE_BUILD_TYPE}")
endif ()
message("|| C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} "
"${CMAKE_CXX_COMPILER_WRAPPER}")
message("|| C++ Compiler exec : ${CMAKE_CXX_COMPILER}")
message("|| OpenMP compile flags : ${OpenMP_CXX_FLAGS}")
message("|| CUDA compiler ID : ${CMAKE_CUDA_COMPILER_ID}")
message("|| CUDA compiler Version : ${CMAKE_CUDA_COMPILER_VERSION}")
message("|| CUDA Compiler : ${CMAKE_CUDA_COMPILER}")
message("|| CUDA Compiler exec : ${CUDA_NVCC_EXECUTABLE}")
message("|| CUDA Compile flags : ${CMAKE_CUDA_FLAGS}")
message("|| CUDA ARCHS : ${CMAKE_CUDA_ARCHITECTURES}")
#message("|| NeonCXXFlags : ${NeonCXXFlags}")
#message("|| NeonCUDAFlags : ${NeonCUDAFlags}")
message("\\===================================================")
# Usefull to debug cmake
# https://jeremimucha.com/2021/01/cmake-fundamentals-part3/
# get_target_property(interfaceLibs NeonDeveloperLib INTERFACE_COMPILE_OPTIONS)
# set(info ${interfaceLibs}[CXX_COMPILER_ID])
# message(STATUS "NeonDeveloperLib INTERFACE_LINK_LIBRARIES: ${info}")