Warning, /acts/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 cmake_minimum_required(VERSION 3.14)
0002
0003 # LCG sets CPATH, which gets treated like -I by the compiler. We want to ignore
0004 # warnings from libraries, by unsetting it here, it gets processed by the usual
0005 # target_include_directories call, resulting in the desired -isystem flag.
0006 unset(ENV{CPATH})
0007
0008 # must be set before project(...) call; version module is needed before
0009 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
0010
0011 # determine project version; sets _acts_version and _acts_commit_hash
0012 include(ActsRetrieveVersion)
0013
0014 project(Acts VERSION ${_acts_version} LANGUAGES CXX)
0015
0016 # policy settings
0017
0018 # Steers how project() handles the VERSION option
0019 cmake_policy(SET CMP0048 NEW)
0020
0021 # the `<project_name>_VERSION` variables set by `setup(... VERSION ...)` have
0022 # only local scope, i.e. they are not accessible her for dependencies added
0023 # via `add_subdirectory`. this overrides the `project(...)` function for
0024 # sub-projects such that the resulting `<project_name>_VERSION` has
0025 # global scope and is accessible within the main project later on.
0026 macro(project)
0027 _project(${ARGN})
0028 set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}" CACHE INTERNAL "")
0029 endmacro()
0030
0031 # Controls the way python is located
0032 if(POLICY CMP0094)
0033 cmake_policy(SET CMP0094 NEW)
0034 endif()
0035
0036 # Controls behavior of DOWNLOAD_EXTRACT_TIMESTAMP
0037 if(POLICY CMP0135)
0038 cmake_policy(SET CMP0135 NEW)
0039 endif()
0040
0041 # Use boost's cmake config files
0042 if(POLICY CMP0167)
0043 cmake_policy(SET CMP0167 NEW)
0044 endif()
0045
0046 # build options
0047
0048 # all options and compile-time parameters must be defined here for clear
0049 # visibility and to make them available everywhere
0050 #
0051 # NOTE if you are adding a new option make sure that is defined in such a way
0052 # that it is off/empty by default. if you think that is not possible, then
0053 # it probably is not an optional component.
0054 # core related options
0055 # Formatting needs to be preserved here for parsing
0056 # gersemi: off
0057 set(ACTS_PARAMETER_DEFINITIONS_HEADER "" CACHE FILEPATH "Use a different (track) parameter definitions header")
0058 set(ACTS_SOURCELINK_SBO_SIZE "" CACHE STRING "Customize the SBO size used by SourceLink")
0059 option(ACTS_FORCE_ASSERTIONS "Force assertions regardless of build type" OFF)
0060 # external library options
0061 option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
0062 option(ACTS_USE_SYSTEM_LIBS "Use system libraries by default" OFF)
0063 # plugins related options
0064 option(ACTS_USE_SYSTEM_ACTSVG "Use the ActSVG system library" ${ACTS_USE_SYSTEM_LIBS})
0065 option(ACTS_USE_SYSTEM_COVFIE "Use a system-provided covfie installation" ${ACTS_USE_SYSTEM_LIBS})
0066 option(ACTS_SETUP_COVFIE "If we want to set up covfie" OFF)
0067 option(ACTS_SETUP_DETRAY "If we want to set up detray" OFF)
0068 option(ACTS_USE_SYSTEM_VECMEM "Use a system-provided vecmem installation" ${ACTS_USE_SYSTEM_LIBS})
0069 option(ACTS_SETUP_VECMEM "If we want to set up vecmem" OFF)
0070 option(ACTS_USE_SYSTEM_TRACCC "Use a system-provided traccc installation" ${ACTS_USE_SYSTEM_LIBS})
0071 option(ACTS_USE_SYSTEM_NLOHMANN_JSON "Use nlohmann::json provided by the system instead of the bundled version" ${ACTS_USE_SYSTEM_LIBS})
0072 option(ACTS_USE_SYSTEM_PYBIND11 "Use a system installation of pybind11" ${ACTS_USE_SYSTEM_LIBS} )
0073 option(ACTS_USE_SYSTEM_MODULEMAPGRAPH "Use a system installation of ModuleMapGraph" ${ACTS_USE_SYSTEM_LIBS})
0074 option(ACTS_USE_SYSTEM_EIGEN3 "Use a system-provided eigen3" ON)
0075 option(ACTS_USE_SYSTEM_GBL "Use a system-provided General Broken Lines (GBL) from Mille" OFF)
0076 option(ACTS_USE_SYSTEM_MILLE "Use a system-provided Mille" ON)
0077
0078 option(ACTS_BUILD_PLUGIN_ACTSVG "Build SVG display plugin" OFF)
0079 option(ACTS_BUILD_PLUGIN_ARROW "Build Apache Arrow/Parquet plugin" OFF)
0080 option(ACTS_ARROW_ISOLATED
0081 "Statically link arrow/parquet into libActsPluginArrow and hide their \
0082 symbols, so they cannot collide with other arrow consumers in the same \
0083 process (e.g. pyarrow's bundled libarrow). Disable only if your arrow \
0084 install is ABI-compatible with every other arrow consumer that will be \
0085 loaded alongside ACTS."
0086 ON
0087 )
0088 option(ACTS_BUILD_PLUGIN_DD4HEP "Build DD4hep plugin" OFF)
0089 option(ACTS_BUILD_PLUGIN_EDM4HEP "Build EDM4hep plugin" OFF)
0090 option(ACTS_BUILD_PLUGIN_FPEMON "Build FPE monitoring plugin" OFF)
0091 option(ACTS_BUILD_PLUGIN_GEOMODEL "Build GeoModel plugin" OFF)
0092 option(ACTS_BUILD_PLUGIN_TRACCC "Build Traccc plugin" OFF)
0093 option(ACTS_ENABLE_CUDA "Enable CUDA for the gnn/Traccc plugins" OFF)
0094 option(ACTS_BUILD_PLUGIN_GEANT4 "Build Geant4 plugin" OFF)
0095 option(ACTS_BUILD_PLUGIN_GNN "Build the GNN plugin" OFF)
0096 option(ACTS_GNN_ENABLE_ONNX "Build the Onnx backend for the gnn plugin" OFF)
0097 option(ACTS_GNN_ENABLE_TORCH "Build the torchscript backend for the gnn plugin" ON)
0098 option(ACTS_GNN_ENABLE_MODULEMAP "Enable Module-Map-based graph construction" OFF)
0099 option(ACTS_GNN_ENABLE_TENSORRT "Enable the native TensorRT inference modules" OFF)
0100 option(ACTS_BUILD_PLUGIN_JSON "Build json plugin" OFF)
0101 option(ACTS_BUILD_PLUGIN_GBL "Build General Broken Lines (GBL) plugin from Mille" OFF)
0102 option(ACTS_BUILD_PLUGIN_MILLE "Build Mille plugin" OFF)
0103 option(ACTS_BUILD_PLUGIN_ONNX "Build ONNX plugin" OFF)
0104 option(ACTS_BUILD_PLUGIN_ROOT "Build ROOT plugin" OFF)
0105 option(ACTS_SETUP_ANNOY "Explicitly set up Annoy for the project" OFF)
0106 # python related options
0107 option(ACTS_BUILD_PYTHON_WHEEL "Settings to build for python deployment with scikit-build-core" OFF)
0108 option(ACTS_BUILD_PYTHON_BINDINGS "Build python bindings for all enabled components" OFF)
0109 option(ACTS_GENERATE_PYTHON_STUBS "Generate Python stub files (.pyi) using pybind11-stubgen via uv" OFF)
0110 # fatras related options
0111 option(ACTS_BUILD_FATRAS "Build FAst TRAcking Simulation package" OFF)
0112 option(ACTS_BUILD_FATRAS_GEANT4 "Build Geant4 Fatras package" OFF)
0113 # alignment related options
0114 option(ACTS_BUILD_ALIGNMENT "Build Alignment package" OFF)
0115 # traccc related options
0116 option(ACTS_BUILD_TRACCC "Build traccc GPU tracking package" OFF)
0117 # examples related options
0118 option(ACTS_BUILD_EXAMPLES "Build basic examples components" OFF)
0119 option(ACTS_BUILD_EXAMPLES_DD4HEP "Build DD4hep-based code in the examples" OFF)
0120 option(ACTS_BUILD_EXAMPLES_EDM4HEP "Build EDM4hep-based code in the examples" OFF)
0121 option(ACTS_BUILD_EXAMPLES_FASTJET "Build FastJet plugin" OFF)
0122 option(ACTS_BUILD_EXAMPLES_GEANT4 "Build Geant4-based code in the examples" OFF)
0123 option(ACTS_BUILD_EXAMPLES_GNN "Build the GNN example code" OFF)
0124 option(ACTS_BUILD_EXAMPLES_HASHING "Build Hashing-based code in the examples" OFF)
0125 option(ACTS_BUILD_EXAMPLES_PARQUET "Build Arrow/Parquet-based code in the examples" OFF)
0126 option(ACTS_BUILD_EXAMPLES_PODIO "Build Podio-based code in the examples" OFF)
0127 option(ACTS_BUILD_EXAMPLES_PYTHIA8 "Build Pythia8-based code in the examples" OFF)
0128 option(ACTS_BUILD_EXAMPLES_ROOT "Build modules based on ROOT I/O" OFF)
0129 option(ACTS_BUILD_ANALYSIS_APPS "Build Analysis applications in the examples" OFF)
0130 # test related options
0131 option(ACTS_BUILD_BENCHMARKS "Build benchmarks" OFF)
0132 option(ACTS_BUILD_INTEGRATIONTESTS "Build integration tests" OFF)
0133 option(ACTS_BUILD_UNITTESTS "Build unit tests" OFF)
0134 if(ACTS_BUILD_UNITTESTS AND ACTS_BUILD_EXAMPLES)
0135 set(_default_examples_unit_tests ON)
0136 else()
0137 set(_default_examples_unit_tests OFF)
0138 endif()
0139 option(ACTS_BUILD_EXAMPLES_UNITTESTS "Build unit tests" ${_default_examples_unit_tests}) # default: ACTS_BUILD_UNITTESTS AND ACTS_BUILD_EXAMPLES
0140 option(ACTS_RUN_CLANG_TIDY "Run clang-tidy static analysis" OFF)
0141 # other options
0142 option(ACTS_BUILD_DOCS "Build documentation" OFF)
0143 option(ACTS_SETUP_BOOST "Explicitly set up Boost for the project" ON)
0144 option(ACTS_SETUP_EIGEN3 "Explicitly set up Eigen3 for the project" ON)
0145 option(ACTS_BUILD_ODD "Build the OpenDataDetector" OFF)
0146 # profiling related options
0147 option(ACTS_ENABLE_CPU_PROFILING "Enable CPU profiling using gperftools" OFF)
0148 option(ACTS_ENABLE_MEMORY_PROFILING "Enable memory profiling using gperftools" OFF)
0149 set(ACTS_GPERF_INSTALL_DIR "" CACHE STRING "Hint to help find gperf if profiling is enabled")
0150
0151 option(ACTS_ENABLE_LOG_FAILURE_THRESHOLD "Enable failing on log messages with level above certain threshold" OFF)
0152 set(ACTS_LOG_FAILURE_THRESHOLD "" CACHE STRING "Log level above which an exception should be automatically thrown. If ACTS_ENABLE_LOG_FAILURE_THRESHOLD is set and this is unset, this will enable a runtime check of the log level.")
0153 option(ACTS_COMPILE_HEADERS "Generate targets to compile header files" ON)
0154 # gersemi: on
0155
0156 # handle option inter-dependencies and the everything flag
0157 # NOTE: ordering is important here. dependencies must come before dependees
0158 include(ActsOptionHelpers)
0159
0160 # any examples component activates the general examples option
0161 set_option_if(
0162 ACTS_BUILD_EXAMPLES
0163 ACTS_BUILD_EXAMPLES_DD4HEP
0164 OR
0165 ACTS_BUILD_EXAMPLES_EDM4HEP
0166 OR
0167 ACTS_BUILD_EXAMPLES_FASTJET
0168 OR
0169 ACTS_BUILD_EXAMPLES_GEANT4
0170 OR
0171 ACTS_BUILD_EXAMPLES_GNN
0172 OR
0173 ACTS_BUILD_EXAMPLES_HASHING
0174 OR
0175 ACTS_BUILD_EXAMPLES_PARQUET
0176 OR
0177 ACTS_BUILD_EXAMPLES_PODIO
0178 OR
0179 ACTS_BUILD_EXAMPLES_PYTHIA8
0180 OR
0181 ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS
0182 OR
0183 ACTS_BUILD_EXAMPLES_ROOT
0184 )
0185 # core plugins might be required by examples or depend on each other
0186 set_option_if(ACTS_BUILD_EXAMPLES_DD4HEP ACTS_BUILD_ODD)
0187 set_option_if(
0188 ACTS_BUILD_PLUGIN_DD4HEP
0189 ACTS_BUILD_EXAMPLES_DD4HEP
0190 OR
0191 ACTS_BUILD_EXAMPLES_EDM4HEP
0192 )
0193 set_option_if(ACTS_BUILD_PLUGIN_EDM4HEP ACTS_BUILD_EXAMPLES_EDM4HEP)
0194 set_option_if(ACTS_BUILD_EXAMPLES_PODIO ACTS_BUILD_EXAMPLES_EDM4HEP)
0195 set_option_if(ACTS_BUILD_PLUGIN_ARROW ACTS_BUILD_EXAMPLES_PARQUET)
0196 set_option_if(ACTS_BUILD_PLUGIN_GEANT4 ACTS_BUILD_EXAMPLES_GEANT4)
0197 set_option_if(
0198 ACTS_BUILD_PLUGIN_ROOT
0199 ACTS_BUILD_EXAMPLES_ROOT
0200 OR
0201 ACTS_BUILD_PLUGIN_DD4HEP
0202 )
0203 set_option_if(
0204 ACTS_BUILD_PLUGIN_IDENTIFICATION
0205 ACTS_BUILD_PLUGIN_ROOT
0206 OR
0207 ACTS_BUILD_PLUGIN_EDM4HEP
0208 OR
0209 ACTS_BUILD_EXAMPLES
0210 )
0211 set_option_if(ACTS_BUILD_PLUGIN_JSON ACTS_BUILD_EXAMPLES)
0212 set_option_if(ACTS_BUILD_FATRAS ACTS_BUILD_EXAMPLES)
0213 set_option_if(ACTS_BUILD_FATRAS ACTS_BUILD_EXAMPLES_FASTJET)
0214 set_option_if(ACTS_BUILD_PLUGIN_GNN ACTS_BUILD_EXAMPLES_GNN)
0215 set_option_if(ACTS_BUILD_PLUGIN_FPEMON ACTS_BUILD_EXAMPLES)
0216 set_option_if(ACTS_BUILD_PLUGIN_JSON ACTS_BUILD_PLUGIN_TRACCC)
0217 set_option_if(ACTS_BUILD_PLUGIN_ACTSVG ACTS_BUILD_PLUGIN_TRACCC)
0218 set_option_if(
0219 ACTS_ENABLE_CUDA
0220 ACTS_GNN_ENABLE_MODULEMAP
0221 AND
0222 ACTS_BUILD_PLUGIN_GNN
0223 )
0224
0225 set_option_if(ACTS_BUILD_PYTHON_BINDINGS ACTS_BUILD_PYTHON_WHEEL)
0226 set_option_if(ACTS_BUILD_ALIGNMENT ACTS_BUILD_PLUGIN_MILLE)
0227 set_option_if(ACTS_BUILD_TRACCC ACTS_BUILD_PLUGIN_TRACCC)
0228 set_option_if(ACTS_BUILD_PLUGIN_JSON ACTS_BUILD_TRACCC)
0229 set_option_if(ACTS_SETUP_DETRAY ACTS_BUILD_TRACCC)
0230 set_option_if(ACTS_SETUP_VECMEM ACTS_SETUP_DETRAY)
0231 set_option_if(ACTS_SETUP_COVFIE ACTS_SETUP_DETRAY)
0232 set_option_if(ACTS_BUILD_PLUGIN_ACTSVG ACTS_SETUP_DETRAY)
0233
0234 # feature tests
0235 include(CheckCXXSourceCompiles)
0236
0237 # We need to set the ORIGIN token based on the system we are compiling for
0238 if(APPLE)
0239 set(_acts_rpath_origin "@loader_path")
0240 else()
0241 set(_acts_rpath_origin "\$ORIGIN")
0242 endif()
0243
0244 # Set flags dependent whether we build ACTS in the default configuration or for deployment in pip with scikit-build-core
0245 if(ACTS_BUILD_PYTHON_WHEEL)
0246 # Check if skbuild is running
0247 if("${SKBUILD}" STREQUAL "2")
0248 message(
0249 STATUS
0250 "Build with skbuild as ${SKBUILD_PROJECT_NAME},${SKBUILD_PROJECT_VERSION_FULL} (${SKBUILD_STATE})"
0251 )
0252 else()
0253 message(WARNING "scikit-build-core not detected for building wheel")
0254 endif()
0255
0256 # Set installation paths for proper python package creation
0257 # CMAKE_PREFIX_PATH should be site-packages (steered by scikit-build-core)
0258 set(CMAKE_INSTALL_BINDIR ${SKBUILD_NULL_DIR}) # Don't install binaries/scripts
0259 set(CMAKE_INSTALL_LIBDIR "acts")
0260 set(CMAKE_INSTALL_INCLUDEDIR ${SKBUILD_NULL_DIR}) # Don't install headers
0261 set(CMAKE_INSTALL_DATAROOTDIR "acts/share")
0262 set(CMAKE_INSTALL_DATADIR "acts/share")
0263 set(CMAKE_INSTALL_RPATH "${_acts_rpath_origin}")
0264 set(_acts_python_install_dir "acts")
0265 set(_acts_python_modules_rpath "${_acts_rpath_origin}")
0266 elseif(PROJECT_IS_TOP_LEVEL)
0267 include(GNUInstallDirs)
0268 set(CMAKE_INSTALL_RPATH "${_acts_rpath_origin}/../${CMAKE_INSTALL_LIBDIR}")
0269 set(_acts_python_install_dir "python/acts")
0270 set(_acts_python_modules_rpath
0271 "${_acts_rpath_origin}/../../${CMAKE_INSTALL_LIBDIR}"
0272 )
0273 endif()
0274
0275 include(ActsCompilerOptions) # default compile options
0276 include(ActsComponentsHelpers) # handle components via add_..._if commands
0277 include(ActsStaticAnalysis)
0278
0279 acts_disable_static_analysis() # disable static analysis for thirdparty dependencies, will be enabled later for the main code
0280
0281 if(PROJECT_IS_TOP_LEVEL)
0282 # place build products in `<build>/bin` and `<build>/lib` for simple use
0283 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
0284 "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}"
0285 )
0286 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
0287 "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
0288 )
0289 endif()
0290
0291 # This needs to happen before we set up any targets
0292 if(ACTS_FORCE_ASSERTIONS)
0293 message(
0294 STATUS
0295 "Injecting headers to force assertions. This can have side-effects, USE WITH CAUTION!"
0296 )
0297 include_directories(
0298 BEFORE
0299 SYSTEM
0300 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/assert_include
0301 )
0302 endif()
0303
0304 # minimal dependency versions. they are defined here in a single place so
0305 # they can be easily upgraded, although they might not be used if the
0306 # dependency is included via `add_subdirectory(...)`.
0307 set(_acts_actsvg_version 0.4.56)
0308 set(_acts_boost_version 1.78.0)
0309 set(_acts_dd4hep_version 1.26)
0310 set(_acts_geant4_version 11.1.3)
0311 set(_acts_edm4hep_version 1.0)
0312 set(_acts_edm4hep_fallback_version 0.10.5)
0313 set(_acts_eigen3_version 3.4.0)
0314 set(_acts_podio_version 1.0.1) # will try this first
0315 set(_acts_podio_fallback_version 0.17.4) # if not found, will try this one
0316 set(_acts_doxygen_version 1.9.4)
0317 set(_acts_hepmc3_version 3.2.4)
0318 set(_acts_nlohmanjson_version 3.11.3)
0319 set(_acts_mille_version 01.00.00)
0320 set(_acts_gbl_version 04.00.04)
0321 set(_acts_onnxruntime_version 1.12.0)
0322 set(_acts_geomodel_version 6.8.0)
0323 set(_acts_root_version 6.28.04) # first version with C++20 support
0324 set(_acts_tbb_version 2020.1)
0325 set(_acts_pythia8_version 8.310)
0326 set(_acts_pybind11_version 3.0.1)
0327 set(_acts_traccc_version 1.4.0)
0328 set(_acts_covfie_version 0.15.2)
0329 set(_acts_vecmem_version 1.25.0)
0330 set(_acts_annoy_version 1.17.3)
0331 set(_acts_fastjet_version 3.4.1)
0332 set(_acts_arrow_version 21.0.0)
0333
0334 # Help with compiler flags discovery
0335 include(ActsFunctions)
0336
0337 # Include the sources for the external dependencies.
0338 include(ActsExternSources)
0339
0340 # required packages
0341 if(ACTS_SETUP_BOOST)
0342 # Enable both program_options and unit_test_framework to reduce complexity
0343 # Also Cuda tests seem to use program_options
0344 if(
0345 ACTS_BUILD_ANALYSIS_APPS
0346 OR ACTS_BUILD_UNITTESTS
0347 OR ACTS_BUILD_INTEGRATIONTESTS
0348 OR ACTS_BUILD_BENCHMARKS
0349 )
0350 find_package(
0351 Boost
0352 ${_acts_boost_version}
0353 REQUIRED
0354 COMPONENTS program_options unit_test_framework
0355 )
0356 else()
0357 find_package(Boost ${_acts_boost_version} REQUIRED COMPONENTS)
0358 endif()
0359
0360 if(Boost_VERSION VERSION_EQUAL "1.85.0")
0361 set(_boost_version_severity WARNING)
0362 if(ACTS_BUILD_EXAMPLES)
0363 set(_boost_version_severity FATAL_ERROR)
0364 endif()
0365 message(
0366 ${_boost_version_severity}
0367 "Boost 1.85.0 is known to be broken (https://github.com/boostorg/container/issues/273). Please use a different version."
0368 )
0369 endif()
0370 endif()
0371
0372 if(ACTS_SETUP_EIGEN3)
0373 if(ACTS_USE_SYSTEM_EIGEN3)
0374 find_package(Eigen3 REQUIRED CONFIG)
0375
0376 if(DEFINED Eigen3_VERSION)
0377 if(Eigen3_VERSION VERSION_LESS _acts_eigen3_version)
0378 message(
0379 FATAL_ERROR
0380 "Eigen3 ${Eigen3_VERSION} is too old (need >= 3.4.0)"
0381 )
0382 endif()
0383 if(Eigen3_VERSION VERSION_GREATER_EQUAL 6.0.0)
0384 message(
0385 FATAL_ERROR
0386 "Eigen3 ${Eigen3_VERSION} is not supported (need < 6.0.0)"
0387 )
0388 endif()
0389 else()
0390 message(
0391 WARNING
0392 "Eigen3 version unknown - cannot verify version requirements"
0393 )
0394 endif()
0395 else()
0396 add_subdirectory(thirdparty/eigen3)
0397 endif()
0398 # get the first include path so we can nicely print where we get eigen from
0399 get_target_property(
0400 _eigen3_include_dirs
0401 Eigen3::Eigen
0402 INTERFACE_INCLUDE_DIRECTORIES
0403 )
0404 if(_eigen3_include_dirs)
0405 list(GET _eigen3_include_dirs 0 _eigen3_first_include_dir)
0406 endif()
0407
0408 message(
0409 STATUS
0410 "Found Eigen3 at: ${_eigen3_first_include_dir} (${Eigen3_VERSION})"
0411 )
0412 endif()
0413
0414 # CUDA settings are collected here in a macro, so that they can be reused by different plugins
0415 macro(enable_cuda)
0416 enable_language(CUDA)
0417 set(CMAKE_CUDA_STANDARD 20 CACHE STRING "CUDA C++ standard to use")
0418 set(CMAKE_CUDA_STANDARD_REQUIRED
0419 ON
0420 CACHE BOOL
0421 "Force the C++ standard requirement"
0422 )
0423 if(NOT CMAKE_CUDA_ARCHITECTURES)
0424 set(CMAKE_CUDA_ARCHITECTURES
0425 "75;80;86;90"
0426 CACHE STRING
0427 "CUDA architectures to generate code for"
0428 )
0429 endif()
0430 set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -G")
0431 set(CMAKE_CUDA_FLAGS
0432 "${CMAKE_CUDA_FLAGS} --extended-lambda --dopt=on --generate-line-info --expt-relaxed-constexpr"
0433 )
0434 endmacro()
0435
0436 # optional packages
0437 #
0438 # find packages explicitly for each component even if this means searching for
0439 # the same package twice. This avoids having complex if/else trees to sort out
0440 # when a particular package is actually needed.
0441 if(ACTS_BUILD_PYTHON_BINDINGS)
0442 find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)
0443 if(ACTS_USE_SYSTEM_PYBIND11)
0444 find_package(pybind11 CONFIG REQUIRED)
0445 else()
0446 add_subdirectory(thirdparty/pybind11)
0447 endif()
0448 endif()
0449 if(ACTS_BUILD_PLUGIN_ACTSVG)
0450 if(ACTS_USE_SYSTEM_ACTSVG)
0451 find_package(actsvg ${_acts_actsvg_version} REQUIRED CONFIG)
0452 else()
0453 add_subdirectory(thirdparty/actsvg)
0454 endif()
0455 endif()
0456 if(ACTS_BUILD_PLUGIN_DD4HEP)
0457 # Explicitly find python so we can more easily override the version
0458 find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)
0459 find_package(
0460 DD4hep
0461 ${_acts_dd4hep_version}
0462 REQUIRED
0463 CONFIG
0464 COMPONENTS DDCore DDDetectors
0465 )
0466 endif()
0467 if(ACTS_BUILD_PLUGIN_JSON)
0468 if(ACTS_USE_SYSTEM_NLOHMANN_JSON)
0469 find_package(nlohmann_json ${_acts_nlohmanjson_version} REQUIRED CONFIG)
0470 else()
0471 add_subdirectory(thirdparty/nlohmann_json)
0472 endif()
0473 endif()
0474 if(ACTS_BUILD_PLUGIN_GBL)
0475 if(ACTS_USE_SYSTEM_GBL)
0476 find_package(GBL ${_acts_gbl_version} REQUIRED CONFIG)
0477 else()
0478 add_subdirectory(thirdparty/GBL)
0479 endif()
0480 endif()
0481 if(ACTS_BUILD_PLUGIN_MILLE)
0482 if(ACTS_USE_SYSTEM_MILLE)
0483 find_package(Mille ${_acts_mille_version} REQUIRED CONFIG)
0484 else()
0485 add_subdirectory(thirdparty/Mille)
0486 endif()
0487 endif()
0488 if(ACTS_BUILD_PLUGIN_GEOMODEL)
0489 find_package(GeoModelCore CONFIG)
0490 if(NOT GeoModelCore_FOUND)
0491 message(
0492 FATAL_ERROR
0493 "GeoModel not found. Please install GeoModel or set ACTS_BUILD_PLUGIN_GEOMODEL to OFF."
0494 )
0495 endif()
0496
0497 if(GeoModelCore_VERSION VERSION_LESS _acts_geomodel_version)
0498 message(
0499 FATAL_ERROR
0500 "GeoModel version ${GeoModelCore_VERSION} is insufficient. Please install GeoModel version ${_acts_geomodel_version} or newer."
0501 )
0502 endif()
0503 # find other GeoModel components of EXACT same version
0504 find_package(GeoModelIO ${GeoModelCore_VERSION} REQUIRED EXACT CONFIG)
0505 endif()
0506 if(ACTS_BUILD_PLUGIN_ROOT)
0507 # In the ATLAS build, the ROOT find_package call does not find VDT unless these variables are set.
0508 # This should not affect other environments.
0509 find_package(VDT QUIET)
0510 if(VDT_FOUND)
0511 set(VDT_INCLUDE_DIR "${VDT_INCLUDE_DIR}" CACHE PATH "")
0512 set(VDT_LIBRARY "${VDT_vdt_LIBRARY}" CACHE FILEPATH "")
0513 endif()
0514
0515 find_package(
0516 ROOT
0517 ${_acts_root_version}
0518 REQUIRED
0519 CONFIG
0520 COMPONENTS Geom Graf Tree RIO Hist
0521 )
0522 endif()
0523 if(ACTS_BUILD_ANALYSIS_APPS)
0524 find_package(
0525 ROOT
0526 ${_acts_root_version}
0527 REQUIRED
0528 CONFIG
0529 COMPONENTS Geom Graf
0530 )
0531 endif()
0532 if(ACTS_BUILD_PLUGIN_GNN)
0533 if(ACTS_ENABLE_CUDA)
0534 find_package(CUDAToolkit REQUIRED)
0535 enable_cuda()
0536 message(STATUS "Build GNN plugin with CUDA")
0537 else()
0538 message(STATUS "Build GNN plugin for CPU only")
0539 endif()
0540 if(ACTS_GNN_ENABLE_TORCH)
0541 find_package(Torch REQUIRED)
0542 if(ACTS_ENABLE_CUDA)
0543 add_subdirectory(thirdparty/FRNN)
0544 endif()
0545 endif()
0546 if(ACTS_GNN_ENABLE_MODULEMAP)
0547 if(ACTS_USE_SYSTEM_MODULEMAPGRAPH)
0548 find_package(ModuleMapGraph REQUIRED COMPONENTS CPU GPU)
0549 else()
0550 add_subdirectory(thirdparty/ModuleMapGraph)
0551 endif()
0552 endif()
0553 endif()
0554 if(ACTS_BUILD_PLUGIN_ONNX OR ACTS_GNN_ENABLE_ONNX)
0555 find_package(onnxruntime ${_acts_onnxruntime_version} MODULE REQUIRED)
0556 endif()
0557 if(ACTS_BUILD_PLUGIN_EDM4HEP)
0558 find_package(EDM4HEP ${_acts_edm4hep_version} CONFIG)
0559 if(NOT EDM4HEP_FOUND)
0560 message(
0561 STATUS
0562 "EDM4hep not found, trying version ${_acts_edm4hep_fallback_version}"
0563 )
0564 find_package(EDM4HEP ${_acts_edm4hep_fallback_version} CONFIG REQUIRED)
0565 endif()
0566 find_package(podio ${_acts_podio_version} CONFIG)
0567 if(NOT podio_FOUND)
0568 message(
0569 STATUS
0570 "Podio not found, trying ${_acts_podio_fallback_version} version"
0571 )
0572 find_package(podio ${_acts_podio_fallback_version} CONFIG REQUIRED)
0573 endif()
0574 find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Core)
0575 endif()
0576 if(ACTS_BUILD_PLUGIN_GEANT4)
0577 find_package(Geant4 ${_acts_geant4_version} REQUIRED CONFIG COMPONENTS gdml)
0578 endif()
0579 if(ACTS_BUILD_PLUGIN_ARROW)
0580 find_package(Arrow REQUIRED CONFIG)
0581 find_package(Parquet REQUIRED CONFIG)
0582 find_package(ArrowDataset REQUIRED CONFIG)
0583 # Arrow's package config requires an exact version match, so enforce our
0584 # minimum supported major version manually instead.
0585 string(REPLACE "." ";" _acts_arrow_version_list ${_acts_arrow_version})
0586 list(GET _acts_arrow_version_list 0 _acts_arrow_version_major)
0587 if(Arrow_VERSION_MAJOR LESS _acts_arrow_version_major)
0588 message(
0589 FATAL_ERROR
0590 "Found Arrow ${Arrow_VERSION}, but at least ${_acts_arrow_version} is required"
0591 )
0592 endif()
0593 endif()
0594
0595 if(ACTS_SETUP_VECMEM)
0596 if(ACTS_USE_SYSTEM_VECMEM)
0597 find_package(vecmem ${_acts_vecmem_version} REQUIRED)
0598 else()
0599 add_subdirectory(thirdparty/vecmem)
0600 endif()
0601 # Make the "VecMem language code" available for the whole project.
0602 list(APPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}")
0603 endif()
0604
0605 if(ACTS_SETUP_COVFIE)
0606 if(ACTS_USE_SYSTEM_COVFIE)
0607 find_package(covfie ${_acts_covfie_version} REQUIRED CONFIG)
0608 else()
0609 add_subdirectory(thirdparty/covfie)
0610 endif()
0611 endif()
0612
0613 if(ACTS_SETUP_DETRAY)
0614 # HACK: Temporary logic (aka technical debt) to make the detray component
0615 # work in traccc.
0616 option(DETRAY_SETUP_VECMEM "" FALSE)
0617 option(DETRAY_SETUP_NLOHMANN "" FALSE)
0618 option(DETRAY_SETUP_EIGEN3 "" FALSE)
0619 option(DETRAY_SETUP_ACTSVG "" FALSE)
0620 option(DETRAY_SETUP_COVFIE "" FALSE)
0621 option(DETRAY_SVG_DISPLAY "" TRUE)
0622 if(ACTS_BUILD_TRACCC)
0623 option(DETRAY_BUILD_TEST_UTILS "" TRUE)
0624 set(DETRAY_GENERATE_METADATA
0625 "itk_metadata"
0626 CACHE STRING
0627 "Semicolon-separated list of metadata generator scripts to run in this build"
0628 )
0629 endif()
0630
0631 add_subdirectory(Detray)
0632 endif()
0633
0634 if(ACTS_BUILD_TRACCC)
0635 # HACK: Temporary logic (aka technical debt) to make the traccc
0636 # component work. Remove this ASAP.
0637 option(TRACCC_USE_ROOT "" FALSE)
0638 option(TRACCC_SETUP_ACTS "" FALSE)
0639 option(TRACCC_SETUP_VECMEM "" FALSE)
0640 find_package(TBB ${_acts_tbb_version} CONFIG)
0641 if(NOT TBB_FOUND)
0642 set(TRACCC_SETUP_TBB TRUE CACHE BOOL "")
0643 else()
0644 set(TRACCC_SETUP_TBB FALSE CACHE BOOL "")
0645 endif()
0646
0647 # traccc also depends on vecmem and covfie, but those plugins should always
0648 # be enabled if traccc is.
0649 if(ACTS_USE_SYSTEM_TRACCC)
0650 find_package(traccc ${_acts_traccc_version} REQUIRED CONFIG)
0651 else()
0652 add_subdirectory(thirdparty/traccc)
0653 endif()
0654 endif()
0655
0656 # examples dependencies
0657 if(ACTS_BUILD_EXAMPLES)
0658 set(THREADS_PREFER_PTHREAD_FLAG ON)
0659 find_package(Threads REQUIRED)
0660
0661 set(_acts_hepmc3_components "search")
0662 if(ACTS_BUILD_EXAMPLES_ROOT)
0663 list(APPEND _acts_hepmc3_components "rootIO")
0664 endif()
0665
0666 find_package(
0667 HepMC3
0668 ${_acts_hepmc3_version}
0669 REQUIRED
0670 CONFIG
0671 COMPONENTS ${_acts_hepmc3_components}
0672 )
0673
0674 # HepMC3 only introduced a proper HepMC3::HepMC3 target in 3.2.6
0675 if(${HEPMC3_VERSION} VERSION_LESS 3.2.6)
0676 add_library(HepMC3::HepMC3 SHARED IMPORTED)
0677 set_property(
0678 TARGET HepMC3::HepMC3
0679 PROPERTY IMPORTED_LOCATION "${HEPMC3_LIB}"
0680 )
0681 target_include_directories(
0682 HepMC3::HepMC3
0683 INTERFACE "${HEPMC3_INCLUDE_DIR}"
0684 )
0685 endif()
0686 if(ACTS_BUILD_EXAMPLES_ROOT)
0687 # for simplicity always request all potentially required components.
0688 find_package(
0689 ROOT
0690 ${_acts_root_version}
0691 REQUIRED
0692 CONFIG
0693 COMPONENTS Core Geom Graf GenVector Hist Tree TreePlayer
0694 )
0695 endif()
0696 if(ACTS_BUILD_EXAMPLES_FASTJET)
0697 find_package(FastJet ${_acts_fastjet_version} REQUIRED)
0698 endif()
0699 if(ACTS_BUILD_EXAMPLES_DD4HEP AND ACTS_BUILD_EXAMPLES_GEANT4)
0700 find_package(
0701 DD4hep
0702 ${_acts_dd4hep_version}
0703 REQUIRED
0704 CONFIG
0705 COMPONENTS DDCore DDG4 DDDetectors
0706 )
0707 elseif(ACTS_BUILD_EXAMPLES_DD4HEP)
0708 find_package(
0709 DD4hep
0710 ${_acts_dd4hep_version}
0711 REQUIRED
0712 CONFIG
0713 COMPONENTS DDCore DDDetectors
0714 )
0715 endif()
0716 if(ACTS_BUILD_EXAMPLES_PYTHIA8)
0717 find_package(Pythia8 ${_acts_pythia8_version} REQUIRED)
0718 endif()
0719 if(ACTS_SETUP_ANNOY OR ACTS_BUILD_EXAMPLES_HASHING)
0720 add_subdirectory(thirdparty/Annoy)
0721 endif()
0722 endif()
0723 # other dependencies
0724 if(ACTS_BUILD_DOCS)
0725 find_package(Doxygen ${_acts_doxygen_version} REQUIRED)
0726 endif()
0727
0728 acts_enable_static_analysis() # enable static analysis for the main code, after dependencies are set up
0729
0730 # core library, core plugins, and other components
0731 add_component(Core Core)
0732 add_component_if(Fatras Fatras ACTS_BUILD_FATRAS)
0733 add_component_if(Alignment Alignment ACTS_BUILD_ALIGNMENT)
0734 add_subdirectory(Plugins)
0735
0736 add_subdirectory_if(thirdparty/OpenDataDetector ACTS_BUILD_ODD)
0737
0738 # Examples
0739 add_subdirectory_if(Examples ACTS_BUILD_EXAMPLES)
0740
0741 # Python bindings
0742 add_subdirectory_if(Python ACTS_BUILD_PYTHON_BINDINGS)
0743
0744 # automated tests and benchmarks
0745 if(ACTS_BUILD_BENCHMARKS OR ACTS_BUILD_INTEGRATIONTESTS OR ACTS_BUILD_UNITTESTS)
0746 enable_testing() # must be set in the main CMakeLists.txt
0747 add_subdirectory(Tests)
0748 endif()
0749
0750 # documentation, adding unconditionally but will only set up docs build if configured
0751 add_subdirectory(docs)
0752
0753 # create cmake configuration files and environment setup script
0754 include(ActsCreatePackageConfig)
0755 include(ActsCreateSetup)