-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
94 lines (75 loc) · 2.41 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
cmake_minimum_required(VERSION 3.9...3.17)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
project(search LANGUAGES CXX)
# Check if we can compile CUDA on this system.
include(CheckLanguage)
check_language(CUDA)
set(CPU_ONLY OFF CACHE BOOL "Build without GPU support?")
if(CMAKE_CUDA_COMPILER AND NOT CPU_ONLY)
set(HAVE_CUDA 1)
enable_language(CUDA)
add_definitions(-DHAVE_CUDA=1)
# Set the CUDA compile options if we are using a recent CUDA compiler.
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0)
set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "-std=c++17")
set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
endif()
else()
message(STATUS "Not building for GPU.")
message(STATUS "CMAKE_CUDA_COMPILER = ${CMAKE_CUDA_COMPILER}")
message(STATUS "CPU only = ${CPU_ONLY}")
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
add_subdirectory(lib/pybind11)
set(CMAKE_CXX_STANDARD 17)
include_directories(
include/
include/eigen
)
# Create the python module via pybind11.
pybind11_add_module(search MODULE
src/kbmod/search/bindings.cpp
)
set_target_properties(search PROPERTIES
CXX_VISIBILITY_PRESET "hidden"
PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}"
)
if(ipo_supported)
set_property(TARGET search PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
target_compile_options(search PRIVATE $<$<COMPILE_LANGUAGE:CXX>:
-O3
-fvisibility=hidden
-fopenmp
>)
target_link_libraries(search PRIVATE
-lgomp
)
# If we have CUDA, build the kernel libraries and link them in as well.
if(HAVE_CUDA)
message(STATUS "Building CUDA Libraries")
add_library(searchcu STATIC
src/kbmod/search/kernels/image_kernels.cu
src/kbmod/search/kernels/kernel_memory.cu
src/kbmod/search/kernels/kernels.cu
)
set_target_properties(searchcu PROPERTIES
POSITION_INDEPENDENT_CODE ON
CUDA_VISIBILITY_PRESET "hidden"
CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON
PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}"
)
if(ipo_supported)
set_property(TARGET searchcu PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
target_link_libraries(search PRIVATE searchcu)
else()
message(STATUS "Skipping CUDA Libraries")
endif()