-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
114 lines (98 loc) · 3.21 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
cmake_minimum_required(VERSION 3.12)
project(_batoid CXX)
# set(CMAKE_VERBOSE_MAKEFILE True)
cmake_policy(SET CMP0063 NEW) # Compile the static lib with hidden visibility.
cmake_policy(SET CMP0148 OLD)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE True)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
if (DEFINED ENV{CMAKE_COVER})
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
endif()
include_directories(include)
find_package(pybind11 REQUIRED)
set(SRC_FILES
src/asphere.cpp
src/batoid.cpp
src/bicubic.cpp
src/coating.cpp
src/dualView.cpp
src/medium.cpp
src/obscuration.cpp
src/paraboloid.cpp
src/plane.cpp
src/polynomialSurface.cpp
src/quadric.cpp
src/rayVector.cpp
src/sphere.cpp
src/sum.cpp
src/surface.cpp
src/tilted.cpp
src/table.cpp
)
set(PYSRC_FILES
pysrc/asphere.cpp
pysrc/batoid.cpp
pysrc/bicubic.cpp
pysrc/coating.cpp
pysrc/medium.cpp
pysrc/obscuration.cpp
pysrc/paraboloid.cpp
pysrc/plane.cpp
pysrc/polynomialSurface.cpp
pysrc/quadric.cpp
pysrc/rayVector.cpp
pysrc/sphere.cpp
pysrc/sum.cpp
pysrc/surface.cpp
pysrc/tilted.cpp
pysrc/table.cpp
)
include(CheckCXXCompilerFlag)
macro(ADD_CXX_FLAG_IF_AVAIL TARG FLAG FLAG_NAME)
if(NOT "${FLAG}" STREQUAL "")
check_cxx_compiler_flag("${FLAG}" ${FLAG_NAME})
if(${FLAG_NAME})
target_compile_options(${TARG} INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${FLAG}>)
endif()
endif()
endmacro()
add_library(batoid-compile-flags INTERFACE)
add_cxx_flag_if_avail(batoid-compile-flags "-Wno-unused-value" CXX_W_NO_UNUSED_VALUE)
add_cxx_flag_if_avail(batoid-compile-flags "-Wno-stringop-overread" CXX_W_NO_STRINGOP_OVERREAD)
if (DEFINED ENV{BATOID_GPU})
add_cxx_flag_if_avail(batoid-compile-flags "-Wno-openmp-mapping" CXX_W_NO_OPENMP_MAPPING)
add_cxx_flag_if_avail(batoid-compile-flags "-fopenmp" CXX_FOPENMP)
target_compile_options(batoid-compile-flags INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -Wno-openmp-mapping -Wno-unknown-cuda-version -I/global/cfs/cdirs/m1759/csdaley/software/perlmutter/llvm/12-main-2020Dec20/include>
)
set(ALL_FILES ${SRC_FILES} ${PYSRC_FILES})
add_definitions(-DBATOID_GPU)
pybind11_add_module(_batoid SYSTEM ${ALL_FILES})
target_link_libraries(_batoid PUBLIC batoid-compile-flags "-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -Wno-openmp-mapping -Wno-unknown-cuda-version -I/global/cfs/cdirs/m1759/csdaley/software/perlmutter/llvm/12-main-2020Dec20/include")
set_target_properties(_batoid
PROPERTIES
DEFINE_SYMBOL ""
)
else()
add_library(batoid ${SRC_FILES})
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(batoid batoid-compile-flags OpenMP::OpenMP_CXX)
else()
target_link_libraries(batoid batoid-compile-flags)
endif()
pybind11_add_module(_batoid SYSTEM ${PYSRC_FILES})
target_link_libraries(_batoid PRIVATE batoid INTERFACE batoid-compile-flags)
endif()