forked from acts-project/traccc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
317 lines (286 loc) · 10.2 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# TRACCC library, part of the ACTS project (R&D line)
#
# (c) 2021-2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0
# Set up the project.
cmake_minimum_required( VERSION 3.9 )
project( traccc VERSION 0.12.0 LANGUAGES CXX )
# Set up the used C++ standard(s).
set( CMAKE_CXX_STANDARD 17 CACHE STRING "The (host) C++ standard to use" )
set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable (host) C++ extensions" )
set( CMAKE_CUDA_STANDARD 17 CACHE STRING "The (CUDA) C++ standard to use" )
set( CMAKE_CUDA_EXTENSIONS FALSE CACHE BOOL "Disable (CUDA) C++ extensions" )
set( CMAKE_SYCL_STANDARD 17 CACHE STRING "The (SYCL) C++ standard to use" )
set( CMAKE_HIP_STANDARD 17 CACHE STRING "The (HIP) C++ standard to use" )
# Flag controlling whether warnings should make the build fail.
option( TRACCC_FAIL_ON_WARNINGS
"Make the build fail on compiler/linker warnings" FALSE )
# Standard CMake include(s).
include( GNUInstallDirs )
# Explicitly set the output directory for the binaries. Such that if this
# project is included by another project, the main project's configuration would
# win out.
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}" CACHE PATH
"Directory for the built binaries" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH
"Directory for the built libraries" )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH
"Directory for the built static libraries" )
# Include the traccc CMake code.
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
include( traccc-functions )
# Check if CUDA is available.
include( CheckLanguage )
check_language( CUDA )
set( TRACCC_BUILD_CUDA_DEFAULT FALSE )
if( CMAKE_CUDA_COMPILER )
set( TRACCC_BUILD_CUDA_DEFAULT TRUE )
endif()
# Flags controlling which parts of traccc to build.
option( TRACCC_BUILD_CUDA "Build the CUDA sources included in traccc"
${TRACCC_BUILD_CUDA_DEFAULT} )
option( TRACCC_BUILD_HIP "Build the HIP sources included in traccc" FALSE)
option( TRACCC_BUILD_SYCL "Build the SYCL sources included in traccc" FALSE )
option( TRACCC_BUILD_FUTHARK "Build the Futhark sources included in traccc"
FALSE )
option( TRACCC_BUILD_KOKKOS "Build the Kokkos sources included in traccc"
FALSE )
option( TRACCC_BUILD_ALPAKA "Build the Alpaka sources included in traccc"
FALSE )
option( TRACCC_BUILD_TESTING "Build the (unit) tests of traccc" TRUE )
option( TRACCC_BUILD_EXAMPLES "Build the examples of traccc" TRUE )
# Flags controlling what traccc should use.
option( TRACCC_USE_SYSTEM_LIBS "Use system libraries be default" FALSE )
option( TRACCC_USE_ROOT "Use ROOT in the build (if needed)" TRUE )
# Clean up.
unset( TRACCC_BUILD_CUDA_DEFAULT )
# Set up VecMem.
option( TRACCC_SETUP_VECMEM
"Set up the VecMem target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_VECMEM
"Pick up an existing installation of VecMem from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_VECMEM )
if( TRACCC_USE_SYSTEM_VECMEM )
find_package( vecmem 0.7.0 REQUIRED COMPONENTS LANGUAGE )
else()
add_subdirectory( extern/vecmem )
# Make the "VecMem language code" available for the whole project.
include( "${VECMEM_LANGUAGE_DIR}/vecmem-check-language.cmake" )
endif()
endif()
# Set up Eigen3.
option( TRACCC_SETUP_EIGEN3
"Set up the Eigen3 target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_EIGEN3
"Pick up an existing installation of Eigen3 from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_EIGEN3 )
if( TRACCC_USE_SYSTEM_EIGEN3 )
find_package( Eigen3 REQUIRED )
else()
add_subdirectory( extern/eigen3 )
endif()
endif()
# Set up Thrust.
option( TRACCC_SETUP_THRUST
"Set up the Thrust target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_THRUST
"Pick up an existing installation of Thrust from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_THRUST )
if( TRACCC_USE_SYSTEM_THRUST )
find_package( Thrust REQUIRED )
else()
add_subdirectory( extern/thrust )
endif()
endif()
# Set up an IMPORTED library on top of the Thrust library/libraries. One that
# the TRACCC/Detray code could depend on publicly.
set( TRACCC_THRUST_OPTIONS "" CACHE STRING
"Extra options for configuring how Thrust should be used" )
mark_as_advanced( TRACCC_THRUST_OPTIONS )
thrust_create_target( traccc::Thrust ${TRACCC_THRUST_OPTIONS} )
# Set up rocThrust.
option( TRACCC_SETUP_ROCTHRUST
"Set up the rocThrust target(s) explicitly" FALSE )
option( TRACCC_USE_SYSTEM_ROCTHRUST
"Pick up an existing installation of rocThrust from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_ROCTHRUST )
set( ROCM_WARN_TOOLCHAIN_VAR FALSE CACHE BOOL "Don't print ROCm warnings" )
set( ROCM_ERROR_TOOLCHAIN_VAR FALSE CACHE BOOL "Don't print ROCm errors" )
mark_as_advanced( ROCM_WARN_TOOLCHAIN_VAR ROCM_ERROR_TOOLCHAIN_VAR )
if( TRACCC_USE_SYSTEM_ROCTHRUST )
find_package( rocThrust REQUIRED )
else()
add_subdirectory( extern/rocThrust )
endif()
# Dress up the rocthrust target a little.
target_compile_definitions( rocthrust INTERFACE
THRUST_IGNORE_CUB_VERSION_CHECK )
endif()
# Set up TBB.
option( TRACCC_SETUP_TBB
"Set up the TBB target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_TBB
"Pick up an existing installation of TBB from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_TBB )
if( TRACCC_USE_SYSTEM_TBB )
find_package( TBB REQUIRED )
else()
add_subdirectory( extern/tbb )
endif()
endif()
# Set up Kokkos.
option( TRACCC_SETUP_KOKKOS
"Set up the Kokkos library" ${TRACCC_BUILD_KOKKOS} )
option( TRACCC_USE_SYSTEM_KOKKOS
"Pick up an existing installation of Kokkos from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_KOKKOS )
if( TRACCC_USE_SYSTEM_KOKKOS )
find_package( Kokkos REQUIRED )
else()
add_subdirectory( extern/kokkos )
endif()
endif()
# Set up Alpaka.
option( TRACCC_SETUP_ALPAKA
"Set up the Alpaka library" ${TRACCC_BUILD_ALPAKA})
option( TRACCC_USE_SYSTEM_ALPAKA
"Pick up an existing installation of Alpaka from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_ALPAKA )
if( TRACCC_USE_SYSTEM_ALPAKA )
find_package( alpaka REQUIRED )
else()
add_subdirectory( extern/alpaka )
endif()
endif()
# Set up Algebra Plugins.
option( TRACCC_SETUP_ALGEBRA_PLUGINS
"Set up the Algebra Plugins target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_ALGEBRA_PLUGINS
"Pick up an existing installation of Algebra Plugins from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_ALGEBRA_PLUGINS )
if( TRACCC_USE_SYSTEM_ALGEBRA_PLUGINS )
find_package( algebra-plugins REQUIRED )
else()
add_subdirectory( extern/algebra-plugins )
endif()
endif()
# Set up covfie.
option( TRACCC_SETUP_COVFIE
"Set up the covfie target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_COVFIE
"Pick up an existing installation of covfie from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_COVFIE )
if( TRACCC_USE_SYSTEM_COVFIE )
find_package( covfie REQUIRED )
else()
add_subdirectory( extern/covfie )
endif()
endif()
# Set up dfelibs.
option( TRACCC_SETUP_DFELIBS
"Set up the dfelibs target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_DFELIBS
"Pick up an existing installation of dfelibs from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_DFELIBS )
if( TRACCC_USE_SYSTEM_DFELIBS )
find_package( dfelibs REQUIRED )
else()
add_subdirectory( extern/dfelibs )
endif()
endif()
# Set up Detray.
option( TRACCC_SETUP_DETRAY
"Set up the Detray target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_DETRAY
"Pick up an existing installation of Detray from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_DETRAY )
if( TRACCC_USE_SYSTEM_DETRAY )
find_package( detray REQUIRED )
else()
add_subdirectory( extern/detray )
endif()
endif()
# Set up Acts.
option( TRACCC_SETUP_ACTS
"Set up the Acts target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_ACTS
"Pick up an existing installation of Acts from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_ACTS )
if( TRACCC_USE_SYSTEM_ACTS )
find_package( Acts REQUIRED COMPONENTS PluginJson )
else()
add_subdirectory( extern/acts )
endif()
endif()
# Set up GoogleTest.
include( CTest )
if (BUILD_TESTING AND TRACCC_BUILD_TESTING)
set (TRACCC_DEFAULT_SETUP_GOOGLETEST TRUE)
endif ()
option( TRACCC_SETUP_GOOGLETEST
"Set up the GoogleTest target(s) explicitly" ${TRACCC_DEFAULT_SETUP_GOOGLETEST} )
option( TRACCC_USE_SYSTEM_GOOGLETEST
"Pick up an existing installation of GoogleTest from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_GOOGLETEST )
if( TRACCC_USE_SYSTEM_GOOGLETEST )
find_package( GTest REQUIRED )
else()
add_subdirectory( extern/googletest )
endif()
endif()
option( TRACCC_ENABLE_NVTX_PROFILING
"Use instrument functions to enable fine grained profiling" FALSE )
# option for algebra plugins (ARRAY EIGEN SMATRIX VC VECMEM)
set(TRACCC_ALGEBRA_PLUGINS ARRAY CACHE STRING "Algebra plugin to use in the build")
message(STATUS "Building with plugin type: " ${TRACCC_ALGEBRA_PLUGINS})
add_definitions(-DALGEBRA_PLUGINS_INCLUDE_${TRACCC_ALGEBRA_PLUGINS})
# Build the traccc code.
add_subdirectory( core )
add_subdirectory( device/common )
if( TRACCC_BUILD_CUDA )
add_subdirectory( device/cuda )
endif()
if( TRACCC_BUILD_KOKKOS )
add_subdirectory( device/kokkos )
endif()
if( TRACCC_BUILD_SYCL )
add_subdirectory( device/sycl )
endif()
if( TRACCC_BUILD_ALPAKA )
add_subdirectory( device/alpaka )
endif()
add_subdirectory( io )
add_subdirectory( performance )
add_subdirectory( plugins )
add_subdirectory( simulation )
if ( TRACCC_BUILD_EXAMPLES )
# Find Boost.
find_package( Boost REQUIRED COMPONENTS program_options filesystem)
add_subdirectory( examples )
endif()
# Set up the test(s).
if( BUILD_TESTING AND TRACCC_BUILD_TESTING )
add_subdirectory( tests )
endif()
if(TRACCC_BUILD_FUTHARK)
add_subdirectory(device/futhark)
endif()
# Set up the packaging of the project.
include( traccc-packaging )