-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
286 lines (264 loc) · 12.6 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
cmake_minimum_required(VERSION 3.11)
project(${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX)
option(SCARABEE_USE_OMP "Compile Scarabée with OpenMP for shared memory parallelism" ON)
# Get FetchContent for downloading dependencies
include(FetchContent)
#===============================================================================
# Get Eigen version 3.4.0
message(STATUS "Downloading Eigen")
FetchContent_Declare(eigen
GIT_REPOSITORY https://gitlab.com/HunterBelanger/eigen.git
GIT_TAG fix/uninstall-target
EXCLUDE_FROM_ALL
)
set(BUILD_TESTING OFF)
set(EIGEN_TEST_NOQT ON)
set(EIGEN_BUILD_CMAKE_PACKAGE OFF)
FetchContent_MakeAvailable(eigen)
#===============================================================================
# Get SPDLOG
message(STATUS "Downloading spdlog v1.13.0")
FetchContent_Declare(spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.13.0
EXCLUDE_FROM_ALL
)
set(SPDLOG_BUILD_PIC ON CACHE BOOL "Build position independent code (-fPIC)")
FetchContent_MakeAvailable(spdlog)
#===============================================================================
# Get HTL
message(STATUS "Downloading HTL")
FetchContent_Declare(htl
GIT_REPOSITORY https://github.com/HunterBelanger/htl.git
GIT_TAG master
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(htl)
#===============================================================================
# Get XTL
message(STATUS "Downloading xtl v0.7.7")
FetchContent_Declare(xtl
GIT_REPOSITORY https://github.com/xtensor-stack/xtl.git
GIT_TAG 0.7.7
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(xtl)
#===============================================================================
# Get XSIMD
message(STATUS "Downloading xsimd v12.1.1")
FetchContent_Declare(xsimd
GIT_REPOSITORY https://github.com/xtensor-stack/xsimd.git
GIT_TAG 12.1.1
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(xsimd)
#===============================================================================
# Get XTENSOR
message(STATUS "Downloading xtensor v0.25.0")
FetchContent_Declare(xtensor
GIT_REPOSITORY https://github.com/xtensor-stack/xtensor.git
GIT_TAG 0.25.0
EXCLUDE_FROM_ALL
)
set(XTENSOR_USE_XSIMD ON CACHE BOOL "Enable SIMD acceleration.")
FetchContent_MakeAvailable(xtensor)
#===============================================================================
# Find Pybind11 from Scikit-Build-Core
set(PYBIND11_NEWPYTHON ON)
find_package(pybind11 CONFIG QUIET)
if (NOT pybind11_FOUND)
set(PYBIND11_FINDPYTHON ON)
message(STATUS "Downloading pybind11 v2.12.0")
FetchContent_Declare(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
GIT_TAG v2.12.0
)
FetchContent_MakeAvailable(pybind11)
endif()
execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/get_numpy_includes.py
OUTPUT_VARIABLE NUMPY_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
#===============================================================================
# Get XTENSOR-PYTHON
message(STATUS "Downloading xtensor-python v0.27.0")
FetchContent_Declare(xtensor-python
GIT_REPOSITORY https://github.com/xtensor-stack/xtensor-python.git
GIT_TAG 0.27.0
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(xtensor-python)
message(STATUS "Numpy includes: ${NUMPY_INCLUDE_DIRS}")
#===============================================================================
# Get HDF5
message(STATUS "Downloading HDF5 v1.14.3")
set(HDF5_ENABLE_Z_LIB_SUPPORT OFF)
set(HDF5_EXTERNALLY_CONFIGURED 1)
set(HDF5_ENABLE_SZIP_SUPPORT OFF)
set(HDF5_BUILD_EXAMPLES OFF)
set(HDF5_BUILD_TOOLS OFF)
set(HDF5_BUILD_UTILS OFF)
set(HDF5_BUILD_HL_LIB OFF)
set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(hdf5
GIT_REPOSITORY https://github.com/HDFGroup/hdf5.git
GIT_TAG hdf5-1_14_3
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(hdf5)
#===============================================================================
# Get HighFive
message(STATUS "Downloading HighFive")
set(HIGHFIVE_UNIT_TESTS OFF)
set(HIGHFIVE_TEST_SPAN OFF)
set(HIGHFIVE_EXAMPLES OFF)
set(HIGHFIVE_BUILD_DOCS OFF)
set(HIGHFIVE_FIND_HDF5 OFF)
FetchContent_Declare(HighFive
GIT_REPOSITORY https://github.com/BlueBrain/HighFive.git
GIT_TAG master
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(HighFive)
#===============================================================================
# Get ImApp
message(STATUS "Downloading ImApp")
FetchContent_Declare(ImApp
GIT_REPOSITORY https://github.com/HunterBelanger/ImApp.git
GIT_TAG master
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(ImApp)
#===============================================================================
# Get Cereal
message(STATUS "Downloading Cereal")
set(BUILD_DOC OFF)
set(BUILD_SANDBOX OFF)
set(SKIP_PERFORMANCE_COMPARISON ON)
FetchContent_Declare(cereal
GIT_REPOSITORY https://github.com/USCiLab/cereal.git
GIT_TAG master
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(cereal)
#===============================================================================
# Make python library
pybind11_add_module(_scarabee src/scarabee/_scarabee/constants.cpp
src/scarabee/_scarabee/water.cpp
src/scarabee/_scarabee/logging.cpp
src/scarabee/_scarabee/gauss_kronrod.cpp
src/scarabee/_scarabee/chebyshev.cpp
src/scarabee/_scarabee/math.cpp
src/scarabee/_scarabee/cross_section.cpp
src/scarabee/_scarabee/diffusion_cross_section.cpp
src/scarabee/_scarabee/material.cpp
src/scarabee/_scarabee/nd_library.cpp
src/scarabee/_scarabee/cylindrical_cell.cpp
src/scarabee/_scarabee/cylindrical_flux_solver.cpp
src/scarabee/_scarabee/surface.cpp
src/scarabee/_scarabee/flat_source_region.cpp
src/scarabee/_scarabee/cell.cpp
src/scarabee/_scarabee/empty_cell.cpp
src/scarabee/_scarabee/simple_pin_cell.cpp
src/scarabee/_scarabee/pin_cell.cpp
src/scarabee/_scarabee/cartesian_2d.cpp
src/scarabee/_scarabee/track.cpp
src/scarabee/_scarabee/legendre.cpp
src/scarabee/_scarabee/yamamoto_tabuchi.cpp
src/scarabee/_scarabee/moc_driver.cpp
src/scarabee/_scarabee/moc_plotter.cpp
src/scarabee/_scarabee/criticality_spectrum.cpp
src/scarabee/_scarabee/diffusion_data.cpp
src/scarabee/_scarabee/diffusion_geometry.cpp
src/scarabee/_scarabee/fd_diffusion_driver.cpp
src/scarabee/_scarabee/nem_diffusion_driver.cpp
src/scarabee/_scarabee/fuel_pin.cpp
src/scarabee/_scarabee/guide_tube.cpp
src/scarabee/_scarabee/burnable_poison_pin.cpp
src/scarabee/_scarabee/pwr_assembly.cpp
src/scarabee/_scarabee/reflector_sn.cpp
src/scarabee/_scarabee/spherical_harmonics.cpp
#=================================================
src/scarabee/_scarabee/python/scarabee.cpp
src/scarabee/_scarabee/python/vector.cpp
src/scarabee/_scarabee/python/direction.cpp
src/scarabee/_scarabee/python/logging.cpp
src/scarabee/_scarabee/python/xs1d.cpp
src/scarabee/_scarabee/python/xs2d.cpp
src/scarabee/_scarabee/python/cross_section.cpp
src/scarabee/_scarabee/python/diffusion_cross_section.cpp
src/scarabee/_scarabee/python/material.cpp
src/scarabee/_scarabee/python/nd_library.cpp
src/scarabee/_scarabee/python/cylindrical_cell.cpp
src/scarabee/_scarabee/python/cylindrical_flux_solver.cpp
src/scarabee/_scarabee/python/polar_quadrature.cpp
src/scarabee/_scarabee/python/boundary_condition.cpp
src/scarabee/_scarabee/python/simulation_mode.cpp
src/scarabee/_scarabee/python/track.cpp
src/scarabee/_scarabee/python/cell.cpp
src/scarabee/_scarabee/python/empty_cell.cpp
src/scarabee/_scarabee/python/pin_cell_type.cpp
src/scarabee/_scarabee/python/simple_pin_cell.cpp
src/scarabee/_scarabee/python/pin_cell.cpp
src/scarabee/_scarabee/python/cartesian_2d.cpp
src/scarabee/_scarabee/python/moc_driver.cpp
src/scarabee/_scarabee/python/criticality_spectrum.cpp
src/scarabee/_scarabee/python/diffusion_data.cpp
src/scarabee/_scarabee/python/diffusion_geometry.cpp
src/scarabee/_scarabee/python/fd_diffusion_driver.cpp
src/scarabee/_scarabee/python/nem_diffusion_driver.cpp
src/scarabee/_scarabee/python/pins.cpp
src/scarabee/_scarabee/python/pwr_assembly.cpp
src/scarabee/_scarabee/python/reflector_sn.cpp
src/scarabee/_scarabee/python/water.cpp
)
target_include_directories(_scarabee PRIVATE include)
target_compile_features(_scarabee PRIVATE cxx_std_20)
target_link_libraries(_scarabee PUBLIC xtl xtensor xtensor-python htl HighFive hdf5-static Eigen3::Eigen spdlog::spdlog ImApp::ImApp cereal::cereal)
target_include_directories(_scarabee PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/scarabee/_scarabee/include>
$<BUILD_INTERFACE:${NUMPY_INCLUDE_DIRS}>
)
target_compile_definitions(_scarabee PRIVATE SCARABEE_MAJOR_VERSION=${PROJECT_VERSION_MAJOR})
target_compile_definitions(_scarabee PRIVATE SCARABEE_MINOR_VERSION=${PROJECT_VERSION_MINOR})
target_compile_definitions(_scarabee PRIVATE SCARABEE_PATCH_VERSION=${PROJECT_VERSION_PATCH})
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Comile options for Windows
target_compile_options(_scarabee PRIVATE /W3)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # Compile options for GCC
target_compile_options(_scarabee PRIVATE -W -Wall -Wextra -Wconversion -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Compile options for Clang
target_compile_options(_scarabee PRIVATE -W -Wall -Wextra -Wconversion -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") # Compile options for Intel
target_compile_options(_scarabee PRIVATE -W -Wall -Wextra -Wconversion -Wpedantic)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Comile options for Windows
target_compile_options(_scarabee PRIVATE /O2)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # Compile options for GCC
target_compile_options(_scarabee PRIVATE -O3)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Compile options for Clang
target_compile_options(_scarabee PRIVATE -O3)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") # Compile options for Intel
target_compile_options(_scarabee PRIVATE -O3)
endif()
endif()
# Find OpenMP if desired
if(SCARABEE_USE_OMP)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(_scarabee PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(_scarabee PUBLIC SCARABEE_USE_OMP)
endif()
endif()
if (SKBUILD_PROJECT_NAME)
# Generate stub file for type completion
add_custom_command(TARGET _scarabee POST_BUILD
COMMAND stubgen --include-docstrings -m _scarabee -o ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME}
WORKING_DIRECTORY $<TARGET_FILE_DIR:_scarabee>
COMMENT "Generating Python stub file for _scarabee"
)
# The install directory is the output (wheel) directory
install(TARGETS _scarabee LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME} )
endif()