Warning, /acts/Traccc/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # TRACCC library, part of the ACTS project (R&D line)
0002 #
0003 # (c) 2021-2026 CERN for the benefit of the ACTS project
0004 #
0005 # Mozilla Public License Version 2.0
0006
0007 # Set up the project.
0008 cmake_minimum_required(VERSION 3.25)
0009 project(traccc VERSION 1.6.0 LANGUAGES CXX)
0010
0011 # Set up the used C++ standard(s).
0012 set(CMAKE_CXX_STANDARD 20 CACHE STRING "The (host) C++ standard to use")
0013 set(CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable (host) C++ extensions")
0014 set(CMAKE_CUDA_STANDARD 20 CACHE STRING "The (CUDA) C++ standard to use")
0015 set(CMAKE_CUDA_EXTENSIONS FALSE CACHE BOOL "Disable (CUDA) C++ extensions")
0016 set(CMAKE_SYCL_STANDARD 20 CACHE STRING "The (SYCL) C++ standard to use")
0017 set(CMAKE_HIP_STANDARD 20 CACHE STRING "The (HIP) C++ standard to use")
0018
0019 if(${CMAKE_CXX_STANDARD} LESS 20)
0020 message(
0021 SEND_ERROR
0022 "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}, but traccc requires C++>=20"
0023 )
0024 endif()
0025
0026 # Set the CUDA architecture to build code for.
0027 set(CMAKE_CUDA_ARCHITECTURES
0028 "75"
0029 CACHE STRING
0030 "CUDA architectures to build device code for"
0031 )
0032
0033 # Set the HIP architecture to build code for.
0034 set(CMAKE_HIP_ARCHITECTURES
0035 "gfx1101;gfx90a"
0036 CACHE STRING
0037 "HIP architectures to build device code for"
0038 )
0039
0040 # Flag controlling whether warnings should make the build fail.
0041 option(
0042 TRACCC_FAIL_ON_WARNINGS
0043 "Make the build fail on compiler/linker warnings"
0044 FALSE
0045 )
0046
0047 # Standard CMake include(s).
0048 include(GNUInstallDirs)
0049
0050 # Explicitly set the output directory for the binaries. Such that if this
0051 # project is included by another project, the main project's configuration would
0052 # win out.
0053 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
0054 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}"
0055 CACHE PATH
0056 "Directory for the built binaries"
0057 )
0058 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
0059 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
0060 CACHE PATH
0061 "Directory for the built libraries"
0062 )
0063 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
0064 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
0065 CACHE PATH
0066 "Directory for the built static libraries"
0067 )
0068
0069 # Include the traccc CMake code.
0070 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
0071 include(traccc-functions)
0072
0073 # Temporary setting for the traccc::scalar type, until it can be removed.
0074 set(TRACCC_CUSTOM_SCALARTYPE
0075 "float"
0076 CACHE STRING
0077 "Scalar type to use in the TRACCC code"
0078 )
0079
0080 # Temporary setting for the traccc device log level, until it can be removed.
0081 set(TRACCC_DEVICE_LOG_LVL
0082 "NONE"
0083 CACHE STRING
0084 "Log level for traccc and detray device code"
0085 )
0086
0087 # Flags controlling which parts of traccc to build.
0088 option(TRACCC_BUILD_CUDA "Build the traccc::cuda library" FALSE)
0089 option(
0090 TRACCC_BUILD_CUDA_UTILS
0091 "Build the traccc::cuda_utils library"
0092 ${TRACCC_BUILD_CUDA}
0093 )
0094 option(TRACCC_BUILD_HIP "Build the HIP sources included in traccc" FALSE)
0095 option(TRACCC_BUILD_SYCL "Build the traccc::sycl library" FALSE)
0096 option(
0097 TRACCC_BUILD_SYCL_UTILS
0098 "Build the traccc::sycl_utils library"
0099 ${TRACCC_BUILD_SYCL}
0100 )
0101 option(TRACCC_BUILD_ALPAKA "Build the Alpaka sources included in traccc" FALSE)
0102 option(
0103 TRACCC_BUILD_IO
0104 "Build the IO module (needed by examples, performance, testing)"
0105 TRUE
0106 )
0107 option(TRACCC_BUILD_PERFORMANCE "Build the performance module" TRUE)
0108 option(TRACCC_BUILD_SIMULATION "Build the simulation module" TRUE)
0109 option(TRACCC_BUILD_TESTING "Build the (unit) tests of traccc" TRUE)
0110 option(TRACCC_BUILD_EXAMPLES "Build the examples of traccc" TRUE)
0111
0112 # Flags controlling what traccc should use.
0113 option(TRACCC_USE_SYSTEM_LIBS "Use system libraries be default" FALSE)
0114 option(TRACCC_USE_SPACK_LIBS "Use Spack libraries by default" FALSE)
0115 option(TRACCC_USE_ROOT "Use ROOT in the build (if needed)" TRUE)
0116
0117 # Check CUDA and SYCL C++ standards
0118 if(${TRACCC_BUILD_CUDA} AND ${CMAKE_CUDA_STANDARD} LESS 20)
0119 message(
0120 SEND_ERROR
0121 "CMAKE_CUDA_STANDARD=${CMAKE_CUDA_STANDARD}, but traccc requires C++>=20"
0122 )
0123 endif()
0124
0125 if(${TRACCC_BUILD_SYCL} AND ${CMAKE_SYCL_STANDARD} LESS 20)
0126 message(
0127 SEND_ERROR
0128 "CMAKE_SYCL_STANDARD=${CMAKE_SYCL_STANDARD}, but traccc requires C++>=20"
0129 )
0130 endif()
0131
0132 if(${TRACCC_BUILD_HIP} AND ${CMAKE_HIP_STANDARD} LESS 20)
0133 message(
0134 SEND_ERROR
0135 "CMAKE_HIP_STANDARD=${CMAKE_HIP_STANDARD}, but traccc requires C++>=20"
0136 )
0137 endif()
0138
0139 # In order to generate specializations for our kernels, we need to have both
0140 # a working Python interpreter, and a list of supported detectors.
0141 find_package(Python COMPONENTS Interpreter REQUIRED)
0142 # The detector types supported by this build of traccc.
0143 set(TRACCC_SUPPORTED_DETECTORS
0144 "default_detector;odd_detector;telescope_detector"
0145 CACHE STRING
0146 "Semicolon-separated list of detector types to support in this build"
0147 )
0148
0149 # Set up build profiling for the project.
0150 if(CTEST_USE_LAUNCHERS)
0151 # Find the bash and time executables.
0152 find_program(BASH_EXECUTABLE bash REQUIRED)
0153 find_program(TIME_EXECUTABLE time REQUIRED)
0154
0155 # Decide what flag to use with the time executable to make it print verbose
0156 # information.
0157 if("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Darwin")
0158 set(TIME_VERBOSE_FLAG "-l")
0159 elseif("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux")
0160 set(TIME_VERBOSE_FLAG "-v")
0161 else()
0162 message(
0163 WARNING
0164 "Build profiling is only supported on Linux and macOS."
0165 "This build will likely fail."
0166 )
0167 set(TIME_VERBOSE_FLAG "")
0168 endif()
0169
0170 # Configure the script that would intercept the build commands and save
0171 # profile logs for them.
0172 configure_file(
0173 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/traccc-ctest.sh.in"
0174 "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/traccc-ctest.sh"
0175 @ONLY
0176 )
0177 set(CMAKE_CTEST_COMMAND
0178 "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/traccc-ctest.sh"
0179 )
0180
0181 # Clean up.
0182 unset(TIME_VERBOSE_FLAG)
0183
0184 # Remove the performance log during a cleaning step.
0185 set_property(
0186 DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
0187 APPEND
0188 PROPERTY
0189 ADDITIONAL_MAKE_CLEAN_FILES
0190 "${CMAKE_CURRENT_BINARY_DIR}/traccc_build_performance.log"
0191 )
0192
0193 # Let the user know what happened.
0194 message(
0195 STATUS
0196 "Saving traccc build performance logs using: ${CMAKE_CTEST_COMMAND}"
0197 )
0198 endif()
0199
0200 # Set up VecMem.
0201 option(TRACCC_SETUP_VECMEM "Set up the VecMem target(s) explicitly" TRUE)
0202 option(
0203 TRACCC_USE_SYSTEM_VECMEM
0204 "Pick up an existing installation of VecMem from the build environment"
0205 ${TRACCC_USE_SYSTEM_LIBS}
0206 )
0207 if(TRACCC_SETUP_VECMEM)
0208 if(TRACCC_USE_SYSTEM_VECMEM)
0209 find_package(vecmem 1.25.0 REQUIRED)
0210 else()
0211 add_subdirectory(extern/vecmem)
0212 endif()
0213 # Make the "VecMem language code" available for the whole project.
0214 list(PREPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}")
0215 endif()
0216
0217 # Set up TBB.
0218 option(TRACCC_SETUP_TBB "Set up the TBB target(s) explicitly" TRUE)
0219 if(TRACCC_USE_SYSTEM_LIBS OR TRACCC_USE_SPACK_LIBS)
0220 set(TRACCC_USE_SYSTEM_TBB_DEFAULT ON)
0221 else()
0222 set(TRACCC_USE_SYSTEM_TBB_DEFAULT OFF)
0223 endif()
0224 option(
0225 TRACCC_USE_SYSTEM_TBB
0226 "Pick up an existing installation of TBB from the build environment"
0227 ${TRACCC_USE_SYSTEM_TBB_DEFAULT}
0228 )
0229 unset(TRACCC_USE_SYSTEM_TBB_DEFAULT)
0230 if(TRACCC_SETUP_TBB)
0231 if(TRACCC_USE_SYSTEM_TBB)
0232 find_package(TBB REQUIRED)
0233 else()
0234 add_subdirectory(extern/tbb)
0235 endif()
0236 endif()
0237
0238 # Set up CCCL.
0239 option(TRACCC_SETUP_THRUST "Set up the Thrust target(s) explicitly" TRUE)
0240 if(TRACCC_USE_SYSTEM_LIBS OR TRACCC_USE_SPACK_LIBS)
0241 set(TRACCC_USE_SYSTEM_THRUST_DEFAULT ON)
0242 else()
0243 set(TRACCC_USE_SYSTEM_THRUST_DEFAULT OFF)
0244 endif()
0245 option(
0246 TRACCC_USE_SYSTEM_THRUST
0247 "Pick up an existing installation of Thrust from the build environment"
0248 ${TRACCC_USE_SYSTEM_THRUST_DEFAULT}
0249 )
0250 unset(TRACCC_USE_SYSTEM_THRUST_DEFAULT)
0251 if(TRACCC_SETUP_THRUST)
0252 if(TRACCC_USE_SYSTEM_THRUST)
0253 find_package(Thrust REQUIRED)
0254 else()
0255 add_subdirectory(extern/cccl)
0256 endif()
0257 endif()
0258
0259 # Set up rocThrust.
0260 option(TRACCC_SETUP_ROCTHRUST "Set up the rocThrust target(s) explicitly" FALSE)
0261 option(
0262 TRACCC_USE_SYSTEM_ROCTHRUST
0263 "Pick up an existing installation of rocThrust from the build environment"
0264 ${TRACCC_USE_SYSTEM_LIBS}
0265 )
0266 if(TRACCC_SETUP_ROCTHRUST)
0267 if(TRACCC_USE_SYSTEM_ROCTHRUST)
0268 find_package(rocthrust REQUIRED)
0269 # Dress up the rocthrust target a little.
0270 target_compile_definitions(
0271 roc::rocthrust
0272 INTERFACE THRUST_IGNORE_CUB_VERSION_CHECK
0273 )
0274 else()
0275 add_subdirectory(extern/rocThrust)
0276 # Dress up the rocthrust target a little.
0277 target_compile_definitions(
0278 rocthrust
0279 INTERFACE THRUST_IGNORE_CUB_VERSION_CHECK
0280 )
0281 endif()
0282 endif()
0283
0284 # Set up DPL if SYCL is built.
0285 option(
0286 TRACCC_SETUP_DPL
0287 "Set up the DPL target(s) explicitly"
0288 ${TRACCC_BUILD_SYCL}
0289 )
0290 if(TRACCC_USE_SYSTEM_LIBS OR TRACCC_USE_SPACK_LIBS)
0291 set(TRACCC_USE_SYSTEM_DPL_DEFAULT ON)
0292 else()
0293 set(TRACCC_USE_SYSTEM_DPL_DEFAULT OFF)
0294 endif()
0295 option(
0296 TRACCC_USE_SYSTEM_DPL
0297 "Pick up an existing installation of DPL from the build environment"
0298 ${TRACCC_USE_SYSTEM_DPL_DEFAULT}
0299 )
0300 unset(TRACCC_USE_SYSTEM_DPL_DEFAULT)
0301 if(TRACCC_SETUP_DPL)
0302 if(TRACCC_USE_SYSTEM_DPL)
0303 # OneDPL determines whether SYCL is supported by asking the C++ compiler
0304 # rather than the SYCL compiler, as a dedicated SYCL compiler is a non-
0305 # standard traccc idea. To override the default behaviour (i.e. OneDPL
0306 # testing the C++ compiler and finding that it does _not_ support SYCL)
0307 # we simply override the support flags. This is fragile, as the flags
0308 # are internal to OneDPL, but it's the best we can do. Note thr flag was
0309 # renamed in https://github.com/uxlfoundation/oneDPL/pull/1949.
0310 set(_sycl_support ON)
0311 set(SYCL_SUPPORT ON)
0312 find_package(oneDPL REQUIRED)
0313 else()
0314 add_subdirectory(extern/dpl)
0315 endif()
0316 # OneDPL attaches the `-fsycl` flag to the C++ compiler, which causes
0317 # it to incorrectly trigger some preprocessor definitions, thereby
0318 # loading SYCL-specific header files which do not exist for e.g. a
0319 # generic clang installation. Therefore, we have to manually wipe the
0320 # compile flags that OneDPL sets.
0321 set_target_properties(
0322 oneDPL
0323 PROPERTIES INTERFACE_COMPILE_OPTIONS "" INTERFACE_LINK_LIBRARIES ""
0324 )
0325 endif()
0326
0327 # Set up Alpaka.
0328 option(TRACCC_SETUP_ALPAKA "Set up the Alpaka library" ${TRACCC_BUILD_ALPAKA})
0329 if(TRACCC_USE_SYSTEM_LIBS OR TRACCC_USE_SPACK_LIBS)
0330 set(TRACCC_USE_SYSTEM_ALPAKA_DEFAULT ON)
0331 else()
0332 set(TRACCC_USE_SYSTEM_ALPAKA_DEFAULT OFF)
0333 endif()
0334 option(
0335 TRACCC_USE_SYSTEM_ALPAKA
0336 "Pick up an existing installation of Alpaka from the build environment"
0337 ${TRACCC_USE_SYSTEM_ALPAKA_DEFAULT}
0338 )
0339 unset(TRACCC_USE_SYSTEM_ALPAKA_DEFAULT)
0340 if(TRACCC_SETUP_ALPAKA)
0341 # Default options for the Alpaka build.
0342 set(alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE
0343 TRUE
0344 CACHE BOOL
0345 "Enable the serial backend of Alpaka"
0346 )
0347 if(TRACCC_USE_SYSTEM_ALPAKA)
0348 find_package(alpaka REQUIRED)
0349 else()
0350 add_subdirectory(extern/alpaka)
0351 endif()
0352 endif()
0353
0354 # Set up covfie.
0355 option(TRACCC_SETUP_COVFIE "Set up the covfie target(s) explicitly" TRUE)
0356 option(
0357 TRACCC_USE_SYSTEM_COVFIE
0358 "Pick up an existing installation of covfie from the build environment"
0359 ${TRACCC_USE_SYSTEM_LIBS}
0360 )
0361 if(TRACCC_SETUP_COVFIE)
0362 if(TRACCC_USE_SYSTEM_COVFIE)
0363 find_package(covfie REQUIRED)
0364 else()
0365 add_subdirectory(extern/covfie)
0366 endif()
0367 endif()
0368
0369 # Set up Acts.
0370 option(TRACCC_SETUP_ACTS "Set up the Acts target(s) explicitly" TRUE)
0371 if(TRACCC_USE_SYSTEM_LIBS OR TRACCC_USE_SPACK_LIBS)
0372 set(TRACCC_USE_SYSTEM_ACTS_DEFAULT ON)
0373 else()
0374 set(TRACCC_USE_SYSTEM_ACTS_DEFAULT OFF)
0375 endif()
0376 option(
0377 TRACCC_USE_SYSTEM_ACTS
0378 "Pick up an existing installation of Acts from the build environment"
0379 ${TRACCC_USE_SYSTEM_ACTS_DEFAULT}
0380 )
0381 unset(TRACCC_USE_SYSTEM_ACTS_DEFAULT)
0382 if(TRACCC_SETUP_ACTS)
0383 if(TRACCC_USE_SYSTEM_ACTS)
0384 find_package(Acts REQUIRED COMPONENTS PluginJson)
0385 find_package(detray REQUIRED)
0386 else()
0387 add_subdirectory(extern/acts)
0388 endif()
0389 endif()
0390
0391 # Set up GoogleTest.
0392 include(CTest)
0393 if(BUILD_TESTING AND TRACCC_BUILD_TESTING)
0394 set(TRACCC_DEFAULT_SETUP_GOOGLETEST TRUE)
0395 endif()
0396 option(
0397 TRACCC_SETUP_GOOGLETEST
0398 "Set up the GoogleTest target(s) explicitly"
0399 ${TRACCC_DEFAULT_SETUP_GOOGLETEST}
0400 )
0401 if(TRACCC_USE_SYSTEM_LIBS OR TRACCC_USE_SPACK_LIBS)
0402 set(TRACCC_USE_SYSTEM_GOOGLETEST_DEFAULT ON)
0403 else()
0404 set(TRACCC_USE_SYSTEM_GOOGLETEST_DEFAULT OFF)
0405 endif()
0406 option(
0407 TRACCC_USE_SYSTEM_GOOGLETEST
0408 "Pick up an existing installation of GoogleTest from the build environment"
0409 ${TRACCC_USE_SYSTEM_GOOGLETEST_DEFAULT}
0410 )
0411 unset(TRACCC_USE_SYSTEM_GOOGLETEST_DEFAULT)
0412 if(TRACCC_SETUP_GOOGLETEST)
0413 if(TRACCC_USE_SYSTEM_GOOGLETEST)
0414 find_package(GTest REQUIRED)
0415 else()
0416 add_subdirectory(extern/googletest)
0417 endif()
0418 endif()
0419
0420 option(
0421 TRACCC_ENABLE_NVTX_PROFILING
0422 "Use instrument functions to enable fine grained profiling"
0423 FALSE
0424 )
0425
0426 # Build the traccc code.
0427 add_subdirectory(core)
0428 add_subdirectory(device/common)
0429 if(TRACCC_BUILD_CUDA_UTILS)
0430 add_subdirectory(device/cuda_utils)
0431 endif()
0432 if(TRACCC_BUILD_CUDA)
0433 add_subdirectory(device/cuda)
0434 endif()
0435 if(TRACCC_BUILD_HIP)
0436 add_subdirectory(device/hip)
0437 endif()
0438 if(TRACCC_BUILD_SYCL_UTILS)
0439 add_subdirectory(device/sycl_utils)
0440 endif()
0441 if(TRACCC_BUILD_SYCL)
0442 add_subdirectory(device/sycl)
0443 endif()
0444 if(TRACCC_BUILD_ALPAKA)
0445 add_subdirectory(device/alpaka)
0446 endif()
0447 if(TRACCC_BUILD_IO)
0448 add_subdirectory(io)
0449 else()
0450 message(
0451 STATUS
0452 "traccc::io not built, traccc::performance and traccc::simulation are forcefully switched off."
0453 )
0454 endif()
0455
0456 if(TRACCC_BUILD_PERFORMANCE)
0457 if(NOT TRACCC_BUILD_IO)
0458 message(
0459 FATAL_ERROR
0460 "traccc::io is disabled, but it is required to build the performance tests."
0461 )
0462 endif()
0463 add_subdirectory(performance)
0464 endif()
0465 if(TRACCC_BUILD_SIMULATION)
0466 if(NOT TRACCC_BUILD_IO)
0467 message(
0468 FATAL_ERROR
0469 "traccc::io is disabled, but it is required to build the simulation."
0470 )
0471 endif()
0472 add_subdirectory(simulation)
0473 endif()
0474
0475 if(TRACCC_BUILD_EXAMPLES)
0476 # Find Boost.
0477 find_package(Boost CONFIG REQUIRED COMPONENTS program_options filesystem)
0478 if(NOT TRACCC_BUILD_IO)
0479 message(
0480 FATAL_ERROR
0481 "traccc::io is disabled, but it is required to build the examples."
0482 )
0483 endif()
0484 if(NOT TRACCC_BUILD_PERFORMANCE)
0485 message(
0486 FATAL_ERROR
0487 "traccc::performance is disabled, but it is required to build the examples."
0488 )
0489 endif()
0490 add_subdirectory(examples)
0491 endif()
0492
0493 # Set up the test(s).
0494 if(BUILD_TESTING AND TRACCC_BUILD_TESTING)
0495 if(NOT TRACCC_BUILD_IO)
0496 message(
0497 FATAL_ERROR
0498 "traccc::io is disabled, but it is required to build the tests."
0499 )
0500 endif()
0501 if(NOT TRACCC_BUILD_SIMULATION)
0502 message(
0503 FATAL_ERROR
0504 "traccc::simulation is disabled, but it is required to build the tests."
0505 )
0506 endif()
0507 if(NOT TRACCC_BUILD_PERFORMANCE)
0508 message(
0509 FATAL_ERROR
0510 "traccc::performance is disabled, but it is required to build the tests."
0511 )
0512 endif()
0513 add_subdirectory(tests)
0514 endif()
0515
0516 # Set up the packaging of the project.
0517 include(traccc-packaging)