-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
146 lines (117 loc) · 4.94 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
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.24.0 FATAL_ERROR)
# set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")
project(CCDGPU LANGUAGES CXX CUDA)
SET(CUDA_SEPARABLE_COMPILATION ON)
set(LIBIGL_WITH_COMISO OFF CACHE BOOL "Use CoMiso")
set(LIBIGL_WITH_EMBREE OFF CACHE BOOL "Use Embree")
set(LIBIGL_WITH_OPENGL OFF CACHE BOOL "Use OpenGL")
set(LIBIGL_WITH_OPENGL_GLFW OFF CACHE BOOL "Use GLFW")
set(LIBIGL_WITH_OPENGL_GLFW_IMGUI OFF CACHE BOOL "Use ImGui")
set(LIBIGL_WITH_PNG OFF CACHE BOOL "Use PNG")
set(LIBIGL_WITH_TETGEN OFF CACHE BOOL "Use Tetgen")
set(LIBIGL_WITH_TRIANGLE OFF CACHE BOOL "Use Triangle")
set(LIBIGL_WITH_PREDICATES ON CACHE BOOL "Use exact predicates")
set(LIBIGL_WITH_XML OFF CACHE BOOL "Use XML")
set(LIBIGL_WITH_PYTHON OFF CACHE BOOL "Use Python")
set(CCDGPU_BROADPHASE_PATH "${PROJECT_SOURCE_DIR}/../broadphase-gpu")
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CCDGPU_TOPLEVEL_PROJECT ON)
else()
set(CCDGPU_TOPLEVEL_PROJECT OFF)
endif()
OPTION(GPUTI_WITH_DOUBLE_PRECISION "use double precision calculation" ON)
OPTION(CCD_TOI_PER_QUERY "record symbolic toi per each query in json" OFF)
# ## Configuration
# set(CCDGPU_EXTERNAL "${CMAKE_CURRENT_SOURCE_DIR}/external")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/recipes/")
include(Warnings)
include(UseColors)
include(CCDGPU_Utils)
# ## the library
add_subdirectory(src)
prepend_current_path(CCDGPU_SOURCES)
CCDGPU_copy_headers(${CCDGPU_SOURCES})
CCDGPU_set_source_group(${CCDGPU_SOURCES})
add_library(${PROJECT_NAME} STATIC ${CCDGPU_SOURCES})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}/include)
# target_link_libraries(CCDGPU PRIVATE warnings::all)
target_compile_definitions(${PROJECT_NAME} PUBLIC NOMINMAX)
if(GPUTI_WITH_DOUBLE_PRECISION)
target_compile_definitions(${PROJECT_NAME} PUBLIC -DGPUTI_USE_DOUBLE_PRECISION)
endif()
if(CCD_TOI_PER_QUERY)
target_compile_definitions(${PROJECT_NAME} PUBLIC CCD_TOI_PER_QUERY)
endif()
# Request that CCDGPU be built with -std=c++11
# As this is a public compile feature anything that links to CCDGPU
# will also build with -std=c++11
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
# ###############################################################################
# CUDA
# ###############################################################################
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -use_fast_math --expt-relaxed-constexpr -gencode arch=compute_86,code=sm_86")
# We need to explicitly state that we need all CUDA files in the CCDGPU
# library to be built with -dc as the member functions could be called by
# other libraries and executables
set_target_properties(${PROJECT_NAME}
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CUDA_ARCHITECTURES native)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:
--generate-line-info
--use_fast_math
--relocatable-device-code=true
# --ptxas-options=-v
# --maxrregcount=7
-fPIC # https://stackoverflow.com/questions/5311515/gcc-fpic-option
>
)
# ###############################################################################
# Required Libraries
# ###############################################################################
include(broadphase)
target_link_libraries(${PROJECT_NAME} PUBLIC STQ::CUDA)
# target_link_libraries(${PROJECT_NAME} PUBLIC gputi)
# libigl
target_link_libraries(${PROJECT_NAME} PUBLIC igl::core)
# JSON
target_link_libraries(${PROJECT_NAME} PUBLIC nlohmann_json::nlohmann_json)
# gmp
if(CCD_TOI_PER_QUERY)
find_package(GMP)
IF(NOT ${GMP_FOUND})
MESSAGE(FATAL_ERROR "Cannot find GMP")
ENDIF()
target_include_directories(${PROJECT_NAME} PUBLIC ${GMP_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${GMP_LIBRARIES})
endif()
# target_link_libraries(${PROJECT_NAME} PUBLIC ipc_toolkit)
# Logger
include(spdlog)
target_link_libraries(${PROJECT_NAME} PUBLIC spdlog::spdlog)
# ###############################################################################
# Binary
# ###############################################################################
if(CCDGPU_TOPLEVEL_PROJECT)
# executable
add_executable(ccdgpu_bin app/main.cu)
set_target_properties(ccdgpu_bin PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET ccdgpu_bin PROPERTY CUDA_ARCHITECTURES native)
target_link_libraries(ccdgpu_bin PRIVATE ${PROJECT_NAME})
if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath,
# so that the static cuda runtime can find it at runtime.
set_property(TARGET ccdgpu_bin PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
target_compile_options(
ccdgpu_bin PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:
--generate-line-info
--use_fast_math
--relocatable-device-code=true
--ptxas-options=-v
# --maxrregcount=7
-fPIC # https://stackoverflow.com/questions/5311515/gcc-fpic-option
>
)
endif()