-
Notifications
You must be signed in to change notification settings - Fork 50
/
CMakeLists.txt
417 lines (373 loc) · 13.9 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# 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.22 )
project( traccc VERSION 0.17.0 LANGUAGES CXX )
# Set up the used C++ standard(s).
set( CMAKE_CXX_STANDARD 20 CACHE STRING "The (host) C++ standard to use" )
set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable (host) C++ extensions" )
set( CMAKE_CUDA_STANDARD 20 CACHE STRING "The (CUDA) C++ standard to use" )
set( CMAKE_CUDA_EXTENSIONS FALSE CACHE BOOL "Disable (CUDA) C++ extensions" )
set( CMAKE_SYCL_STANDARD 20 CACHE STRING "The (SYCL) C++ standard to use" )
set( CMAKE_HIP_STANDARD 20 CACHE STRING "The (HIP) C++ standard to use" )
if(${CMAKE_CXX_STANDARD} LESS 20)
message(SEND_ERROR "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}, but traccc requires C++>=20")
endif()
# 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 )
# Flags controlling which parts of traccc to build.
option( TRACCC_BUILD_CUDA "Build the CUDA sources included in traccc" FALSE )
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_IO "Build the IO module (needed by examples, performance, testing)" TRUE )
option( TRACCC_BUILD_TESTING "Build the (unit) tests of traccc" TRUE )
option( TRACCC_BUILD_BENCHMARKS "Build the benchmarks 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 )
# Check CUDA and SYCL C++ standards
if(${TRACCC_BUILD_CUDA} AND ${CMAKE_CUDA_STANDARD} LESS 20)
message(SEND_ERROR "CMAKE_CUDA_STANDARD=${CMAKE_CUDA_STANDARD}, but traccc requires C++>=20")
endif()
if(${TRACCC_BUILD_SYCL} AND ${CMAKE_SYCL_STANDARD} LESS 20)
message(SEND_ERROR "CMAKE_SYCL_STANDARD=${CMAKE_SYCL_STANDARD}, but traccc requires C++>=20")
endif()
if(${TRACCC_BUILD_HIP} AND ${CMAKE_HIP_STANDARD} LESS 20)
message(SEND_ERROR "CMAKE_HIP_STANDARD=${CMAKE_HIP_STANDARD}, but traccc requires C++>=20")
endif()
# Set up build profiling for the project.
if( CTEST_USE_LAUNCHERS )
# Find the bash and time executables.
find_program( BASH_EXECUTABLE bash REQUIRED )
find_program( TIME_EXECUTABLE time REQUIRED )
# Decide what flag to use with the time executable to make it print verbose
# information.
if( "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Darwin" )
set( TIME_VERBOSE_FLAG "-l" )
elseif( "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux" )
set( TIME_VERBOSE_FLAG "-v" )
else()
message( WARNING "Build profiling is only supported on Linux and macOS."
"This build will likely fail." )
set( TIME_VERBOSE_FLAG "" )
endif()
# Configure the script that would intercept the build commands and save
# profile logs for them.
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/traccc-ctest.sh.in"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/traccc-ctest.sh"
@ONLY )
set( CMAKE_CTEST_COMMAND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/traccc-ctest.sh" )
# Clean up.
unset( TIME_VERBOSE_FLAG )
# Remove the performance log during a cleaning step.
set_property( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_BINARY_DIR}/traccc_build_performance.log" )
# Let the user know what happened.
message( STATUS
"Saving traccc build performance logs using: ${CMAKE_CTEST_COMMAND}" )
endif()
# 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 1.9.0 REQUIRED )
else()
add_subdirectory( extern/vecmem )
# Make the "VecMem language code" available for the whole project.
list( PREPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}" )
endif()
endif()
# Including vecmem-check-language makes sure that the HIP and SYCL languages
# would be picked up from VecMem.
include( vecmem-check-language )
# 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 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 CCCL.
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/cccl )
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 DPL if SYCL is built.
option( TRACCC_SETUP_DPL
"Set up the DPL target(s) explicitly" ${TRACCC_BUILD_SYCL} )
option( TRACCC_USE_SYSTEM_DPL
"Pick up an existing installation of DPL from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_DPL )
if( TRACCC_USE_SYSTEM_DPL )
find_package( DPL REQUIRED )
else()
add_subdirectory( extern/dpl )
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 )
# Default options for the Alpaka build.
set( alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE TRUE CACHE BOOL
"Enable the serial backend of 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()
# Set up Google Benchmark
option( TRACCC_SETUP_BENCHMARKS
"Set up the Google Benchmark target(s) explicitly" TRUE )
option( TRACCC_USE_SYSTEM_BENCHMARKS
"Pick up an existing installation of Google Benchmark from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
if( TRACCC_SETUP_BENCHMARKS )
if( TRACCC_USE_SYSTEM_BENCHMARKS )
find_package( benchmark REQUIRED )
else()
add_subdirectory( extern/benchmark )
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")
# 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()
if ( TRACCC_BUILD_IO )
add_subdirectory( io )
add_subdirectory( performance )
add_subdirectory( simulation )
else()
message(STATUS "traccc::io not built, traccc::performance and traccc::simulation are forcefully switched off.")
endif()
add_subdirectory( plugins )
if ( TRACCC_BUILD_EXAMPLES )
# Find Boost.
find_package( Boost CONFIG REQUIRED COMPONENTS program_options filesystem )
if ( NOT TRACCC_BUILD_IO )
message(FATAL_ERROR "traccc::io is disabled, but it is required to build the examples.")
endif()
add_subdirectory( examples )
endif()
# Set up the test(s).
if( BUILD_TESTING AND TRACCC_BUILD_TESTING )
if ( NOT TRACCC_BUILD_IO )
message(FATAL_ERROR "traccc::io is disabled, but it is required to build the tests.")
endif()
add_subdirectory( tests )
endif()
# Set up the benchmark(s).
if( TRACCC_BUILD_BENCHMARKS )
# Find Boost.
find_package( Boost CONFIG REQUIRED COMPONENTS filesystem )
if ( NOT TRACCC_BUILD_IO )
message(FATAL_ERROR "traccc::io is disabled, but it is required to build the tests.")
endif()
add_subdirectory( benchmarks )
endif()
if(TRACCC_BUILD_FUTHARK)
add_subdirectory(device/futhark)
endif()
# Set up the packaging of the project.
include( traccc-packaging )