-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
109 lines (90 loc) · 3.46 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
cmake_minimum_required(VERSION 3.10.1)
set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")
project(cuMesh LANGUAGES CXX CUDA)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frounding-math -std=c++14 -fPIC")
set(CMAKE_CUDA_STANDARD 14)
SET(CUDA_SEPARABLE_COMPILATION ON)
FIND_PACKAGE(CUDA REQUIRED)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
LIST(APPEND CUDA_NVCC_FLAGS
-gencode arch=compute_75,code=compute_75
-gencode arch=compute_75,code=sm_75
-rdc=true
--expt-relaxed-constexpr
-lineinfo
)
else()
LIST(APPEND CUDA_NVCC_FLAGS -O3
-gencode arch=compute_75,code=compute_75
-gencode arch=compute_75,code=sm_75
-gencode arch=compute_61,code=compute_61
-gencode arch=compute_61,code=sm_61
-rdc=true
--expt-relaxed-constexpr
-lineinfo
)
endif()
#hide variable as SDK now (usually) part of CUDA Toolkit
mark_as_advanced(FORCE CUDA_SDK_ROOT_DIR)
# additional directories where to look for SDK which are
# not yet added in FindCUDA.cmake of CMake
list(APPEND CUDA_SDK_SEARCH_PATH "${CUDA_TOOLKIT_ROOT_DIR}/samples")
# look for required SDK header files as suggested in FindCUDA.cmake
find_path(CUDA_HELPER_INCLUDE_DIR
helper_cuda.h
PATHS ${CUDA_SDK_SEARCH_PATH}
PATH_SUFFIXES "common/inc"
DOC "Location of helper_cuda.h of the CUDA SDK."
NO_DEFAULT_PATH
)
find_path(CUDA_HELPER_INCLUDE_DIR helper_cuda.h DOC "Location of helper_cuda.h of the CUDA SDK.")
mark_as_advanced(FORCE CUDA_HELPER_INCLUDE_DIR)
# either add found path to include search path or show user the
# appropriate CMake variables to tell us where to find the headers
if (CUDA_HELPER_INCLUDE_DIR)
include_directories(${CUDA_HELPER_INCLUDE_DIR})
elseif (NOT CUDA_SDK_ROOT_DIR)
mark_as_advanced(CLEAR CUDA_SDK_ROOT_DIR)
else ()
mark_as_advanced(CLEAR CUDA_HELPER_INCLUDE_DIR)
endif ()
find_package(Thrust REQUIRED)
message(STATUS "find thrust in ${THRUST_INCLUDE_DIR}")
include_directories(${THRUST_INCLUDE_DIR})
include_directories(${THRUST_INCLUDE_DIR}/thrust/system/cuda/detail/)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -ffast-math -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++14 -ffast-math -fPIC -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -ffast-math -fPIC")
endif()
include_directories(external/probabilistic-quadrics)
add_subdirectory(external/polyscope)
FILE(GLOB CU_UTILS_SRC_IMPL
cuMesh/*.cu
cuMesh/**/*.cu
)
FILE(GLOB CU_UTILS_SRC
cuMesh/*.cpp
cuMesh/**/*.cpp)
set(CUDA_LINK_LIBRARIES_KEYWORD PRIVATE)
include_directories(${PROJECT_SOURCE_DIR})
cuda_add_library(cuMesh_Impl ${CU_UTILS_SRC_IMPL} )
TARGET_LINK_LIBRARIES(cuMesh_Impl
PRIVATE ${CUDA_LIBRARIES}
PRIVATE ${CUDA_CUDART_LIBRARY}
PRIVATE ${CUDA_cublas_LIBRARY}
)
message(STATUS ${CU_UTILS_SRC})
add_library(cuMesh SHARED ${CU_UTILS_SRC} )
target_link_libraries(cuMesh
PRIVATE cuMesh_Impl
PRIVATE ${CUDA_LIBRARIES}
PRIVATE ${CUDA_CUDART_LIBRARY}
PRIVATE ${CUDA_cublas_LIBRARY}
PUBLIC polyscope
)
add_subdirectory(tests)