Warning, /acts/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 cmake_minimum_required(VERSION 3.19)
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_SOURCELINK_SBO_SIZE "" CACHE STRING "Customize the SBO size used by SourceLink")
0058 option(ACTS_FORCE_ASSERTIONS "Force assertions regardless of build type" OFF)
0059 option(ACTS_FAIL_ON_WARNINGS "Treat compiler warnings in Acts' own code as errors" OFF)
0060 # code generation related options
0061 set(ACTS_CODEGEN_PREBUILT_DIR "" CACHE PATH "Directory holding pre-generated code; a generated file found there is used verbatim instead of being regenerated. Defaults to prebuilt-codegen/ next to this file when it exists, which is what release source archives ship")
0062 option(ACTS_CODEGEN_REQUIRE_PREBUILT "Fail the configure step instead of running the code generators when pre-generated code is missing" OFF)
0063 # external library options
0064 set(ACTS_USE_ZSTD "AUTO" CACHE STRING "zstd support: AUTO (use if available), ALWAYS (required), NEVER (disabled)")
0065 set_property(CACHE ACTS_USE_ZSTD PROPERTY STRINGS AUTO ALWAYS NEVER)
0066 if(NOT ACTS_USE_ZSTD MATCHES "^(AUTO|ALWAYS|NEVER)$")
0067 message(FATAL_ERROR "ACTS_USE_ZSTD must be AUTO, ALWAYS, or NEVER (got '${ACTS_USE_ZSTD}')")
0068 endif()
0069 option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
0070 option(ACTS_USE_SYSTEM_LIBS "Use system libraries by default" OFF)
0071 # plugins related options
0072 option(ACTS_USE_SYSTEM_ACTSVG "Use the ActSVG system library" ${ACTS_USE_SYSTEM_LIBS})
0073 option(ACTS_SETUP_ACTSVG "If we want to set up actsvg" OFF)
0074 option(ACTS_USE_SYSTEM_COVFIE "Use a system-provided covfie installation" ${ACTS_USE_SYSTEM_LIBS})
0075 option(ACTS_SETUP_COVFIE "If we want to set up covfie" OFF)
0076 option(ACTS_SETUP_DETRAY "If we want to set up detray" OFF)
0077 option(ACTS_USE_SYSTEM_VECMEM "Use a system-provided vecmem installation" ${ACTS_USE_SYSTEM_LIBS})
0078 option(ACTS_SETUP_VECMEM "If we want to set up vecmem" OFF)
0079 option(ACTS_USE_SYSTEM_TRACCC "Use a system-provided traccc installation" ${ACTS_USE_SYSTEM_LIBS})
0080 option(ACTS_USE_SYSTEM_ALPAKA "Use a system-provided Alpaka installation for traccc" ${ACTS_USE_SYSTEM_LIBS})
0081 option(ACTS_USE_SYSTEM_TBB "Use a system-provided TBB installation for traccc" ${ACTS_USE_SYSTEM_LIBS})
0082 option(ACTS_USE_SYSTEM_THRUST "Use a system-provided Thrust (CCCL) installation for traccc; always on if the CUDA toolkit is found" ${ACTS_USE_SYSTEM_LIBS})
0083 option(ACTS_SETUP_THRUST "Set up the Thrust (CCCL) target(s) for traccc" ON)
0084 option(ACTS_USE_SYSTEM_ROCTHRUST "Use the rocThrust installation from ROCm for traccc" ON)
0085 option(ACTS_USE_SYSTEM_DPL "Use a system-provided oneDPL installation for traccc" ${ACTS_USE_SYSTEM_LIBS})
0086 option(ACTS_USE_SYSTEM_GOOGLETEST "Use a system-provided GoogleTest installation for traccc" ${ACTS_USE_SYSTEM_LIBS})
0087 option(ACTS_USE_SYSTEM_NLOHMANN_JSON "Use nlohmann::json provided by the system instead of the bundled version" ${ACTS_USE_SYSTEM_LIBS})
0088 option(ACTS_USE_SYSTEM_PYBIND11 "Use a system installation of pybind11" ${ACTS_USE_SYSTEM_LIBS} )
0089 option(ACTS_USE_SYSTEM_MODULEMAPGRAPH "Use a system installation of ModuleMapGraph" ${ACTS_USE_SYSTEM_LIBS})
0090 option(ACTS_USE_SYSTEM_EIGEN3 "Use a system-provided eigen3" ON)
0091 option(ACTS_USE_SYSTEM_GBL "Use a system-provided General Broken Lines (GBL) from Mille" OFF)
0092 option(ACTS_USE_SYSTEM_MILLE "Use a system-provided Mille" ${ACTS_USE_SYSTEM_LIBS})
0093 option(ACTS_USE_SYSTEM_MP2 "Use a system-provided Millepede-2" ${ACTS_USE_SYSTEM_LIBS})
0094
0095 option(ACTS_BUILD_PLUGIN_ACTSVG "Build SVG display plugin" OFF)
0096 option(ACTS_BUILD_PLUGIN_ARROW "Build Apache Arrow/Parquet plugin" OFF)
0097 option(ACTS_ARROW_ISOLATED
0098 "Statically link arrow/parquet into libActsPluginArrow and hide their \
0099 symbols, so they cannot collide with other arrow consumers in the same \
0100 process (e.g. pyarrow's bundled libarrow). Disable only if your arrow \
0101 install is ABI-compatible with every other arrow consumer that will be \
0102 loaded alongside ACTS."
0103 ON
0104 )
0105 option(ACTS_BUILD_PLUGIN_DD4HEP "Build DD4hep plugin" OFF)
0106 option(ACTS_BUILD_PLUGIN_EDM4HEP "Build EDM4hep plugin" OFF)
0107 option(ACTS_BUILD_PLUGIN_FPEMON "Build FPE monitoring plugin" OFF)
0108 option(ACTS_BUILD_PLUGIN_GEOMODEL "Build GeoModel plugin" OFF)
0109 option(ACTS_BUILD_PLUGIN_TRACCC "Build Traccc plugin" OFF)
0110 option(ACTS_ENABLE_CUDA "Enable CUDA for the gnn/Traccc/CudaMuonSegmentFitting plugins" OFF)
0111 option(ACTS_BUILD_PLUGIN_GEANT4 "Build Geant4 plugin" OFF)
0112 option(ACTS_BUILD_PLUGIN_GNN "Build the GNN plugin" OFF)
0113 option(ACTS_GNN_ENABLE_ONNX "Build the Onnx backend for the gnn plugin" OFF)
0114 option(ACTS_GNN_ENABLE_TORCH "Build the torchscript backend for the gnn plugin" ON)
0115 option(ACTS_GNN_ENABLE_MODULEMAP "Enable Module-Map-based graph construction" OFF)
0116 option(ACTS_GNN_ENABLE_TENSORRT "Enable the native TensorRT inference modules" OFF)
0117 option(ACTS_BUILD_PLUGIN_JSON "Build json plugin" OFF)
0118 option(ACTS_BUILD_PLUGIN_GBL "Build General Broken Lines (GBL) plugin from Mille" OFF)
0119 option(ACTS_BUILD_PLUGIN_MILLE "Build Mille plugin" OFF)
0120 option(ACTS_BUILD_PLUGIN_ONNX "Build ONNX plugin" OFF)
0121 option(ACTS_BUILD_PLUGIN_ROOT "Build ROOT plugin" OFF)
0122 option(ACTS_SETUP_ANNOY "Explicitly set up Annoy for the project" OFF)
0123 # python related options
0124 option(ACTS_BUILD_PYTHON_WHEEL "Settings to build for python deployment with scikit-build-core" OFF)
0125 option(ACTS_BUILD_PYTHON_BINDINGS "Build python bindings for all enabled components" OFF)
0126 option(ACTS_GENERATE_PYTHON_STUBS "Generate Python stub files (.pyi) using pybind11-stubgen via uv" OFF)
0127 # fatras related options
0128 option(ACTS_BUILD_FATRAS "Build FAst TRAcking Simulation package" OFF)
0129 option(ACTS_BUILD_FATRAS_GEANT4 "Build Geant4 Fatras package" OFF)
0130 # alignment related options
0131 option(ACTS_BUILD_ALIGNMENT "Build Alignment package" OFF)
0132 # traccc related options
0133 option(ACTS_BUILD_TRACCC "Build traccc GPU tracking package" OFF)
0134 # examples related options
0135 option(ACTS_BUILD_EXAMPLES "Build basic examples components" OFF)
0136 option(ACTS_BUILD_EXAMPLES_DD4HEP "Build DD4hep-based code in the examples" OFF)
0137 option(ACTS_BUILD_EXAMPLES_EDM4HEP "Build EDM4hep-based code in the examples" OFF)
0138 option(ACTS_BUILD_EXAMPLES_FASTJET "Build FastJet plugin" OFF)
0139 option(ACTS_BUILD_EXAMPLES_GEANT4 "Build Geant4-based code in the examples" OFF)
0140 option(ACTS_BUILD_EXAMPLES_GNN "Build the GNN example code" OFF)
0141 option(ACTS_BUILD_EXAMPLES_HASHING "Build Hashing-based code in the examples" OFF)
0142 option(ACTS_BUILD_EXAMPLES_PARQUET "Build Arrow/Parquet-based code in the examples" OFF)
0143 option(ACTS_BUILD_EXAMPLES_PODIO "Build Podio-based code in the examples" OFF)
0144 option(ACTS_BUILD_EXAMPLES_PYTHIA8 "Build Pythia8-based code in the examples" OFF)
0145 option(ACTS_BUILD_EXAMPLES_ROOT "Build modules based on ROOT I/O" OFF)
0146 option(ACTS_BUILD_EXAMPLES_CUDA_MUON_SEGMENT_FITTING "Build CUDA muon segment fitting example" OFF)
0147 option(ACTS_BUILD_ANALYSIS_APPS "Build Analysis applications in the examples" OFF)
0148 # test related options
0149 option(ACTS_BUILD_BENCHMARKS "Build benchmarks" OFF)
0150 option(ACTS_BUILD_INTEGRATIONTESTS "Build integration tests" OFF)
0151 option(ACTS_BUILD_UNITTESTS "Build unit tests" OFF)
0152 option(ACTS_BUILD_CORE_UNITTESTS "Build Core unit tests" ON) # only relevant if ACTS_BUILD_UNITTESTS is ON
0153 if(ACTS_BUILD_UNITTESTS AND ACTS_BUILD_EXAMPLES)
0154 set(_default_examples_unit_tests ON)
0155 else()
0156 set(_default_examples_unit_tests OFF)
0157 endif()
0158 option(ACTS_BUILD_EXAMPLES_UNITTESTS "Build Examples unit tests" ${_default_examples_unit_tests}) # default: ACTS_BUILD_UNITTESTS AND ACTS_BUILD_EXAMPLES
0159 option(ACTS_RUN_CLANG_TIDY "Run clang-tidy static analysis" OFF)
0160 # traccc options, only relevant if ACTS_BUILD_TRACCC is ON
0161 option(ACTS_TRACCC_BUILD_CUDA "Build the traccc CUDA libraries" ${ACTS_ENABLE_CUDA})
0162 option(ACTS_TRACCC_BUILD_HIP "Build the traccc HIP libraries" OFF)
0163 option(ACTS_TRACCC_BUILD_SYCL "Build the traccc SYCL libraries" OFF)
0164 option(ACTS_TRACCC_BUILD_ALPAKA "Build the traccc Alpaka library" OFF)
0165 option(ACTS_TRACCC_BUILD_IO "Build the traccc IO library" ON)
0166 option(ACTS_TRACCC_BUILD_PERFORMANCE "Build the traccc performance library" OFF)
0167 option(ACTS_TRACCC_BUILD_TESTS "Build the traccc unit tests" ${ACTS_BUILD_UNITTESTS})
0168 option(ACTS_TRACCC_BUILD_EXAMPLES "Build the traccc examples" ${ACTS_BUILD_EXAMPLES})
0169 option(ACTS_TRACCC_ENABLE_NVTX_PROFILING "Instrument the traccc device code for NVTX profiling" OFF)
0170 set(ACTS_TRACCC_SUPPORTED_DETECTORS "default_detector;odd_detector;telescope_detector" CACHE STRING "Semicolon-separated list of detector types that traccc supports")
0171 set(ACTS_TRACCC_DEVICE_LOG_LEVEL "NONE" CACHE STRING "Log level for traccc and detray device code")
0172 # other options
0173 option(ACTS_BUILD_DOCS "Build documentation" OFF)
0174 option(ACTS_SETUP_BOOST "Explicitly set up Boost for the project" ON)
0175 option(ACTS_SETUP_EIGEN3 "Explicitly set up Eigen3 for the project" ON)
0176 option(ACTS_BUILD_ODD "Build the OpenDataDetector" OFF)
0177 # profiling related options
0178 option(ACTS_ENABLE_CPU_PROFILING "Enable CPU profiling using gperftools" OFF)
0179 option(ACTS_ENABLE_MEMORY_PROFILING "Enable memory profiling using gperftools" OFF)
0180 set(ACTS_GPERF_INSTALL_DIR "" CACHE STRING "Hint to help find gperf if profiling is enabled")
0181
0182 option(ACTS_ENABLE_LOG_FAILURE_THRESHOLD "Enable failing on log messages with level above certain threshold" OFF)
0183 option(ACTS_COMPILE_HEADERS "Generate targets to compile header files" ON)
0184 # gersemi: on
0185
0186 # Removed option: warn and drop it from the cache. Setting it used to imply
0187 # ACTS_ENABLE_LOG_FAILURE_THRESHOLD, so ignoring it silently would leave a
0188 # downstream that set only this one with no threshold at all.
0189 if(DEFINED ACTS_LOG_FAILURE_THRESHOLD)
0190 message(
0191 WARNING
0192 "ACTS_LOG_FAILURE_THRESHOLD was removed. Set "
0193 "ACTS_ENABLE_LOG_FAILURE_THRESHOLD=ON and pass the level in the "
0194 "ACTS_LOG_FAILURE_THRESHOLD environment variable instead."
0195 )
0196 unset(ACTS_LOG_FAILURE_THRESHOLD CACHE)
0197 endif()
0198
0199 # handle option inter-dependencies and the everything flag
0200 # NOTE: ordering is important here. dependencies must come before dependees
0201 include(ActsOptionHelpers)
0202
0203 # any examples component activates the general examples option
0204 set_option_if(
0205 ACTS_BUILD_EXAMPLES
0206 ACTS_BUILD_EXAMPLES_DD4HEP
0207 OR
0208 ACTS_BUILD_EXAMPLES_EDM4HEP
0209 OR
0210 ACTS_BUILD_EXAMPLES_FASTJET
0211 OR
0212 ACTS_BUILD_EXAMPLES_GEANT4
0213 OR
0214 ACTS_BUILD_EXAMPLES_GNN
0215 OR
0216 ACTS_BUILD_EXAMPLES_HASHING
0217 OR
0218 ACTS_BUILD_EXAMPLES_PARQUET
0219 OR
0220 ACTS_BUILD_EXAMPLES_PODIO
0221 OR
0222 ACTS_BUILD_EXAMPLES_PYTHIA8
0223 OR
0224 ACTS_BUILD_EXAMPLES_ROOT
0225 OR
0226 ACTS_BUILD_EXAMPLES_CUDA_MUON_SEGMENT_FITTING
0227 )
0228 # core plugins might be required by examples or depend on each other
0229 set_option_if(ACTS_BUILD_EXAMPLES_DD4HEP ACTS_BUILD_ODD)
0230 set_option_if(
0231 ACTS_BUILD_PLUGIN_DD4HEP
0232 ACTS_BUILD_EXAMPLES_DD4HEP
0233 OR
0234 ACTS_BUILD_EXAMPLES_EDM4HEP
0235 )
0236 set_option_if(ACTS_ENABLE_CUDA ACTS_BUILD_EXAMPLES_CUDA_MUON_SEGMENT_FITTING)
0237 set_option_if(ACTS_BUILD_PLUGIN_EDM4HEP ACTS_BUILD_EXAMPLES_EDM4HEP)
0238 set_option_if(ACTS_BUILD_EXAMPLES_PODIO ACTS_BUILD_EXAMPLES_EDM4HEP)
0239 set_option_if(ACTS_BUILD_PLUGIN_ARROW ACTS_BUILD_EXAMPLES_PARQUET)
0240 set_option_if(ACTS_BUILD_PLUGIN_GEANT4 ACTS_BUILD_EXAMPLES_GEANT4)
0241 set_option_if(
0242 ACTS_BUILD_PLUGIN_ROOT
0243 ACTS_BUILD_EXAMPLES_ROOT
0244 OR
0245 ACTS_BUILD_PLUGIN_DD4HEP
0246 )
0247 set_option_if(
0248 ACTS_BUILD_PLUGIN_IDENTIFICATION
0249 ACTS_BUILD_PLUGIN_ROOT
0250 OR
0251 ACTS_BUILD_PLUGIN_EDM4HEP
0252 OR
0253 ACTS_BUILD_EXAMPLES
0254 )
0255 set_option_if(ACTS_BUILD_PLUGIN_JSON ACTS_BUILD_EXAMPLES)
0256 set_option_if(ACTS_BUILD_FATRAS ACTS_BUILD_EXAMPLES)
0257 set_option_if(ACTS_BUILD_FATRAS ACTS_BUILD_EXAMPLES_FASTJET)
0258 set_option_if(ACTS_BUILD_PLUGIN_GNN ACTS_BUILD_EXAMPLES_GNN)
0259 set_option_if(ACTS_BUILD_PLUGIN_FPEMON ACTS_BUILD_EXAMPLES)
0260 set_option_if(ACTS_BUILD_PLUGIN_JSON ACTS_BUILD_PLUGIN_TRACCC)
0261 set_option_if(
0262 ACTS_ENABLE_CUDA
0263 ACTS_GNN_ENABLE_MODULEMAP
0264 AND
0265 ACTS_BUILD_PLUGIN_GNN
0266 )
0267
0268 set_option_if(ACTS_SETUP_VECMEM ACTS_BUILD_PLUGIN_GNN)
0269
0270 set_option_if(ACTS_BUILD_PYTHON_BINDINGS ACTS_BUILD_PYTHON_WHEEL)
0271 set_option_if(ACTS_BUILD_ALIGNMENT ACTS_BUILD_PLUGIN_MILLE)
0272 set_option_if(ACTS_BUILD_TRACCC ACTS_BUILD_PLUGIN_TRACCC)
0273 set(_acts_traccc_build_cuda_utils "${ACTS_TRACCC_BUILD_CUDA}")
0274 set(_acts_traccc_build_hip_utils "${ACTS_TRACCC_BUILD_HIP}")
0275 set(_acts_traccc_build_sycl_utils "${ACTS_TRACCC_BUILD_SYCL}")
0276 if(ACTS_BUILD_TRACCC AND ACTS_TRACCC_BUILD_ALPAKA)
0277 set_option_if(_acts_traccc_build_cuda_utils alpaka_ACC_GPU_CUDA_ENABLE)
0278 set_option_if(_acts_traccc_build_hip_utils alpaka_ACC_GPU_HIP_ENABLE)
0279 set_option_if(_acts_traccc_build_sycl_utils alpaka_ACC_SYCL_ENABLE)
0280 endif()
0281 set_option_if(
0282 ACTS_TRACCC_BUILD_PERFORMANCE
0283 ACTS_TRACCC_BUILD_TESTS
0284 OR
0285 ACTS_TRACCC_BUILD_EXAMPLES
0286 )
0287 set_option_if(ACTS_TRACCC_BUILD_IO ACTS_TRACCC_BUILD_PERFORMANCE)
0288 # Required for traccc
0289 set_option_if(ACTS_SETUP_DETRAY ACTS_BUILD_TRACCC)
0290 set_option_if(ACTS_SETUP_COVFIE ACTS_SETUP_DETRAY)
0291 # Required for detray
0292 set_option_if(ACTS_SETUP_VECMEM ACTS_SETUP_DETRAY)
0293 set_option_if(ACTS_BUILD_PLUGIN_JSON ACTS_SETUP_DETRAY)
0294 # Required for the ActSVG plugin
0295 set_option_if(ACTS_SETUP_ACTSVG ACTS_BUILD_PLUGIN_ACTSVG)
0296
0297 # feature tests
0298 include(CheckCXXSourceCompiles)
0299
0300 # We need to set the ORIGIN token based on the system we are compiling for
0301 if(APPLE)
0302 set(_acts_rpath_origin "@loader_path")
0303 else()
0304 set(_acts_rpath_origin "\$ORIGIN")
0305 endif()
0306
0307 # Set flags dependent whether we build ACTS in the default configuration or for deployment in pip with scikit-build-core
0308 if(ACTS_BUILD_PYTHON_WHEEL)
0309 # Check if skbuild is running
0310 if("${SKBUILD}" STREQUAL "2")
0311 message(
0312 STATUS
0313 "Build with skbuild as ${SKBUILD_PROJECT_NAME},${SKBUILD_PROJECT_VERSION_FULL} (${SKBUILD_STATE})"
0314 )
0315 else()
0316 message(WARNING "scikit-build-core not detected for building wheel")
0317 endif()
0318
0319 # Set installation paths for proper python package creation
0320 # CMAKE_PREFIX_PATH should be site-packages (steered by scikit-build-core)
0321 set(CMAKE_INSTALL_BINDIR ${SKBUILD_NULL_DIR}) # Don't install binaries/scripts
0322 set(CMAKE_INSTALL_LIBDIR "acts")
0323 set(CMAKE_INSTALL_INCLUDEDIR ${SKBUILD_NULL_DIR}) # Don't install headers
0324 set(CMAKE_INSTALL_DATAROOTDIR "acts/share")
0325 set(CMAKE_INSTALL_DATADIR "acts/share")
0326 set(CMAKE_INSTALL_RPATH "${_acts_rpath_origin}")
0327 set(_acts_python_install_dir "acts")
0328 set(_acts_python_modules_rpath "${_acts_rpath_origin}")
0329 elseif(PROJECT_IS_TOP_LEVEL)
0330 include(GNUInstallDirs)
0331 set(CMAKE_INSTALL_RPATH "${_acts_rpath_origin}/../${CMAKE_INSTALL_LIBDIR}")
0332 set(_acts_python_install_dir "python/acts")
0333 set(_acts_python_modules_rpath
0334 "${_acts_rpath_origin}/../../${CMAKE_INSTALL_LIBDIR}"
0335 )
0336 endif()
0337
0338 include(ActsCompilerOptions) # default compile options
0339 include(ActsWarningFlags) # warning flags, applied per-directory to our own code
0340 include(ActsComponentsHelpers) # handle components via add_..._if commands
0341 include(ActsStaticAnalysis)
0342
0343 acts_disable_static_analysis() # disable static analysis for thirdparty dependencies, will be enabled later for the main code
0344
0345 if(PROJECT_IS_TOP_LEVEL)
0346 # place build products in `<build>/bin` and `<build>/lib` for simple use
0347 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
0348 "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}"
0349 )
0350 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
0351 "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
0352 )
0353 endif()
0354
0355 # This needs to happen before we set up any targets
0356 include(ActsForceAssertions)
0357
0358 # minimal dependency versions. they are defined here in a single place so
0359 # they can be easily upgraded, although they might not be used if the
0360 # dependency is included via `add_subdirectory(...)`.
0361 set(_acts_actsvg_version 0.4.57)
0362 set(_acts_boost_version 1.78.0)
0363 set(_acts_dd4hep_version 1.26)
0364 set(_acts_geant4_version 11.1.3)
0365 set(_acts_edm4hep_version 1.0)
0366 # 0.99 is the first release providing the TrackerHit interface, the CovMatrix
0367 # types (edm4hep::TrackState::covMatrix), Track::Nholes and the
0368 # edm4hep::TrackParams enum, all of which the EDM4hep plugin relies on.
0369 set(_acts_edm4hep_fallback_version 0.99)
0370 set(_acts_eigen3_version 5.0.1) # used when building Eigen from source
0371 set(_acts_eigen3_min_version 3.4.0) # minimum version accepted for a system Eigen3
0372 set(_acts_podio_version 1.0.1) # will try this first
0373 set(_acts_podio_fallback_version 0.17.4) # if not found, will try this one
0374 set(_acts_doxygen_version 1.9.4)
0375 set(_acts_hepmc3_version 3.2.4)
0376 set(_acts_nlohmanjson_version 3.11.3)
0377 set(_acts_gbl_version 04.00.05)
0378 set(_acts_mille_version 01.01.02)
0379 set(_acts_mp2_version 05.01.06)
0380 set(_acts_onnxruntime_version 1.12.0)
0381 set(_acts_geomodel_version 6.16.0)
0382 set(_acts_root_version 6.28.04) # first version with C++20 support
0383 set(_acts_tbb_version 2020.1)
0384 set(_acts_pythia8_version 8.310)
0385 set(_acts_pybind11_version 3.0.1)
0386 set(_acts_traccc_version 1.4.0)
0387 set(_acts_covfie_version 0.16.0)
0388 set(_acts_vecmem_version 1.28.0)
0389 set(_acts_annoy_version 1.17.3)
0390 set(_acts_fastjet_version 3.4.1)
0391 set(_acts_arrow_version 21.0.0)
0392
0393 # Help with compiler flags discovery
0394 include(ActsFunctions)
0395
0396 # Include the sources for the external dependencies.
0397 include(ActsExternSources)
0398
0399 # required packages
0400 if(ACTS_SETUP_BOOST)
0401 # Enable both program_options and unit_test_framework to reduce complexity
0402 # Also Cuda tests seem to use program_options
0403 set(_acts_boost_components)
0404 if(
0405 ACTS_BUILD_ANALYSIS_APPS
0406 OR ACTS_BUILD_UNITTESTS
0407 OR ACTS_BUILD_INTEGRATIONTESTS
0408 OR ACTS_BUILD_BENCHMARKS
0409 )
0410 list(APPEND _acts_boost_components program_options unit_test_framework)
0411 endif()
0412
0413 # Only the Mille plugin needs process/filesystem, and neither is part of
0414 # every Boost installation (Boost.Process is a compiled library since Boost
0415 # 1.88). The plugin reports if the one it needs is missing.
0416 find_package(
0417 Boost
0418 ${_acts_boost_version}
0419 REQUIRED
0420 COMPONENTS ${_acts_boost_components}
0421 OPTIONAL_COMPONENTS process filesystem
0422 )
0423
0424 if(Boost_VERSION VERSION_EQUAL "1.85.0")
0425 set(_boost_version_severity WARNING)
0426 if(ACTS_BUILD_EXAMPLES)
0427 set(_boost_version_severity FATAL_ERROR)
0428 endif()
0429 message(
0430 ${_boost_version_severity}
0431 "Boost 1.85.0 is known to be broken (https://github.com/boostorg/container/issues/273). Please use a different version."
0432 )
0433 endif()
0434 endif()
0435
0436 if(ACTS_SETUP_EIGEN3)
0437 if(ACTS_USE_SYSTEM_EIGEN3)
0438 find_package(Eigen3 REQUIRED CONFIG)
0439
0440 if(DEFINED Eigen3_VERSION)
0441 if(Eigen3_VERSION VERSION_LESS _acts_eigen3_min_version)
0442 message(
0443 FATAL_ERROR
0444 "Eigen3 ${Eigen3_VERSION} is too old (need >= ${_acts_eigen3_min_version})"
0445 )
0446 endif()
0447 if(Eigen3_VERSION VERSION_GREATER_EQUAL 6.0.0)
0448 message(
0449 FATAL_ERROR
0450 "Eigen3 ${Eigen3_VERSION} is not supported (need < 6.0.0)"
0451 )
0452 endif()
0453 else()
0454 message(
0455 WARNING
0456 "Eigen3 version unknown - cannot verify version requirements"
0457 )
0458 endif()
0459 else()
0460 add_subdirectory(thirdparty/eigen3)
0461 endif()
0462 # get the first include path so we can nicely print where we get eigen from
0463 get_target_property(
0464 _eigen3_include_dirs
0465 Eigen3::Eigen
0466 INTERFACE_INCLUDE_DIRECTORIES
0467 )
0468 if(_eigen3_include_dirs)
0469 list(GET _eigen3_include_dirs 0 _eigen3_first_include_dir)
0470 endif()
0471
0472 message(
0473 STATUS
0474 "Found Eigen3 at: ${_eigen3_first_include_dir} (${Eigen3_VERSION})"
0475 )
0476 endif()
0477
0478 # CUDA settings are collected here in a macro, so that they can be reused by different plugins
0479 macro(enable_cuda)
0480 enable_language(CUDA)
0481 set(CMAKE_CUDA_STANDARD 20 CACHE STRING "CUDA C++ standard to use")
0482 set(CMAKE_CUDA_STANDARD_REQUIRED
0483 ON
0484 CACHE BOOL
0485 "Force the C++ standard requirement"
0486 )
0487 if(NOT CMAKE_CUDA_ARCHITECTURES)
0488 set(CMAKE_CUDA_ARCHITECTURES
0489 "75;80;86;90"
0490 CACHE STRING
0491 "CUDA architectures to generate code for"
0492 )
0493 endif()
0494 set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -G")
0495 set(CMAKE_CUDA_FLAGS
0496 "${CMAKE_CUDA_FLAGS} --extended-lambda --dopt=on --generate-line-info --expt-relaxed-constexpr"
0497 )
0498 endmacro()
0499
0500 # optional packages
0501 #
0502 # find packages explicitly for each component even if this means searching for
0503 # the same package twice. This avoids having complex if/else trees to sort out
0504 # when a particular package is actually needed.
0505
0506 # nlohmann_json has to be resolved before any other package, because its config
0507 # file defines a non-namespaced `nlohmann_json` compatibility target whenever it
0508 # is searched for without a version. That target clashes with the one the
0509 # bundled build creates, so we have to claim the name first.
0510 if(ACTS_BUILD_PLUGIN_JSON)
0511 if(ACTS_USE_SYSTEM_NLOHMANN_JSON)
0512 find_package(nlohmann_json ${_acts_nlohmanjson_version} REQUIRED CONFIG)
0513 else()
0514 add_subdirectory(thirdparty/nlohmann_json)
0515 endif()
0516 endif()
0517 if(ACTS_BUILD_PYTHON_BINDINGS)
0518 find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)
0519 if(ACTS_USE_SYSTEM_PYBIND11)
0520 find_package(pybind11 CONFIG REQUIRED)
0521 else()
0522 add_subdirectory(thirdparty/pybind11)
0523 endif()
0524 endif()
0525 # Set up ActSVG when requested. The ActSVG plugin enables this by itself.
0526 # Detray reports an error if it needs actsvg and actsvg is not set up.
0527 if(ACTS_SETUP_ACTSVG)
0528 if(ACTS_USE_SYSTEM_ACTSVG)
0529 find_package(actsvg ${_acts_actsvg_version} REQUIRED CONFIG)
0530 else()
0531 add_subdirectory(thirdparty/actsvg)
0532 endif()
0533 endif()
0534 if(ACTS_BUILD_PLUGIN_DD4HEP)
0535 # Explicitly find python so we can more easily override the version
0536 find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)
0537 find_package(
0538 DD4hep
0539 ${_acts_dd4hep_version}
0540 REQUIRED
0541 CONFIG
0542 COMPONENTS DDCore DDDetectors
0543 )
0544 endif()
0545 if(ACTS_BUILD_PLUGIN_GBL)
0546 if(ACTS_USE_SYSTEM_GBL)
0547 find_package(GBL ${_acts_gbl_version} REQUIRED CONFIG)
0548 else()
0549 add_subdirectory(thirdparty/GBL)
0550 endif()
0551 endif()
0552 if(ACTS_BUILD_PLUGIN_MILLE)
0553 if(ACTS_USE_SYSTEM_MILLE)
0554 find_package(Mille ${_acts_mille_version} REQUIRED CONFIG)
0555 else()
0556 add_subdirectory(thirdparty/Mille)
0557 endif()
0558 if(ACTS_USE_SYSTEM_MP2)
0559 find_package(millepedeII ${_acts_mp2_version} REQUIRED CONFIG)
0560 else()
0561 add_subdirectory(thirdparty/Millepede-II)
0562 endif()
0563 endif()
0564 if(ACTS_BUILD_PLUGIN_GEOMODEL)
0565 find_package(GeoModelCore CONFIG)
0566 if(NOT GeoModelCore_FOUND)
0567 message(
0568 FATAL_ERROR
0569 "GeoModel not found. Please install GeoModel or set ACTS_BUILD_PLUGIN_GEOMODEL to OFF."
0570 )
0571 endif()
0572
0573 if(GeoModelCore_VERSION VERSION_LESS _acts_geomodel_version)
0574 message(
0575 FATAL_ERROR
0576 "GeoModel version ${GeoModelCore_VERSION} is insufficient. Please install GeoModel version ${_acts_geomodel_version} or newer."
0577 )
0578 endif()
0579 # find other GeoModel components of EXACT same version
0580 find_package(GeoModelIO ${GeoModelCore_VERSION} REQUIRED EXACT CONFIG)
0581 endif()
0582 if(ACTS_BUILD_PLUGIN_ROOT)
0583 # In the ATLAS build, the ROOT find_package call does not find VDT unless these variables are set.
0584 # This should not affect other environments.
0585 find_package(VDT QUIET)
0586 if(VDT_FOUND)
0587 set(VDT_INCLUDE_DIR "${VDT_INCLUDE_DIR}" CACHE PATH "")
0588 set(VDT_LIBRARY "${VDT_vdt_LIBRARY}" CACHE FILEPATH "")
0589 endif()
0590
0591 find_package(
0592 ROOT
0593 ${_acts_root_version}
0594 REQUIRED
0595 CONFIG
0596 COMPONENTS Geom Graf Tree RIO Hist
0597 )
0598 endif()
0599 if(ACTS_BUILD_ANALYSIS_APPS)
0600 find_package(
0601 ROOT
0602 ${_acts_root_version}
0603 REQUIRED
0604 CONFIG
0605 COMPONENTS Geom Graf
0606 )
0607 endif()
0608 if(ACTS_ENABLE_CUDA)
0609 find_package(CUDAToolkit REQUIRED)
0610 enable_cuda()
0611 message(STATUS "Build ACTS with CUDA")
0612 endif()
0613 if(ACTS_BUILD_PLUGIN_GNN)
0614 if(ACTS_ENABLE_CUDA)
0615 message(STATUS "Build GNN plugin with CUDA")
0616 else()
0617 message(STATUS "Build GNN plugin for CPU only")
0618 endif()
0619 # FRNN and ModuleMapGraph are built from vendored upstream sources, which
0620 # are not ours to keep warning-clean. A normal variable, so it shadows the
0621 # cache entry for the subdirectories added below and is restored before any
0622 # ACTS target follows.
0623 set(_acts_gnn_warning_as_error "${CMAKE_COMPILE_WARNING_AS_ERROR}")
0624 set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
0625 if(ACTS_GNN_ENABLE_TORCH)
0626 find_package(Torch REQUIRED)
0627 if(ACTS_ENABLE_CUDA)
0628 add_subdirectory(thirdparty/FRNN)
0629 endif()
0630 endif()
0631 if(ACTS_GNN_ENABLE_MODULEMAP)
0632 if(ACTS_USE_SYSTEM_MODULEMAPGRAPH)
0633 find_package(ModuleMapGraph REQUIRED COMPONENTS CPU GPU)
0634 else()
0635 add_subdirectory(thirdparty/ModuleMapGraph)
0636 endif()
0637 endif()
0638 set(CMAKE_COMPILE_WARNING_AS_ERROR "${_acts_gnn_warning_as_error}")
0639 endif()
0640 if(ACTS_BUILD_PLUGIN_ONNX OR ACTS_GNN_ENABLE_ONNX)
0641 find_package(onnxruntime ${_acts_onnxruntime_version} MODULE REQUIRED)
0642 endif()
0643 if(ACTS_BUILD_PLUGIN_EDM4HEP)
0644 find_package(EDM4HEP ${_acts_edm4hep_version} CONFIG)
0645 if(NOT EDM4HEP_FOUND)
0646 message(
0647 STATUS
0648 "EDM4hep not found, trying version ${_acts_edm4hep_fallback_version}"
0649 )
0650 find_package(EDM4HEP ${_acts_edm4hep_fallback_version} CONFIG REQUIRED)
0651 endif()
0652 find_package(podio ${_acts_podio_version} CONFIG)
0653 if(NOT podio_FOUND)
0654 message(
0655 STATUS
0656 "Podio not found, trying ${_acts_podio_fallback_version} version"
0657 )
0658 find_package(podio ${_acts_podio_fallback_version} CONFIG REQUIRED)
0659 endif()
0660 find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Core)
0661 endif()
0662 if(ACTS_BUILD_PLUGIN_GEANT4)
0663 find_package(Geant4 ${_acts_geant4_version} REQUIRED CONFIG COMPONENTS gdml)
0664 endif()
0665 if(ACTS_BUILD_PLUGIN_ARROW)
0666 find_package(Arrow REQUIRED CONFIG)
0667 find_package(Parquet REQUIRED CONFIG)
0668 find_package(ArrowDataset REQUIRED CONFIG)
0669 # Arrow's package config requires an exact version match, so enforce our
0670 # minimum supported major version manually instead.
0671 string(REPLACE "." ";" _acts_arrow_version_list ${_acts_arrow_version})
0672 list(GET _acts_arrow_version_list 0 _acts_arrow_version_major)
0673 if(Arrow_VERSION_MAJOR LESS _acts_arrow_version_major)
0674 message(
0675 FATAL_ERROR
0676 "Found Arrow ${Arrow_VERSION}, but at least ${_acts_arrow_version} is required"
0677 )
0678 endif()
0679 endif()
0680
0681 if(ACTS_SETUP_VECMEM)
0682 if(ACTS_USE_SYSTEM_VECMEM)
0683 find_package(vecmem ${_acts_vecmem_version} REQUIRED)
0684 elseif(NOT TARGET vecmem::core)
0685 add_subdirectory(thirdparty/vecmem)
0686 list(PREPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}")
0687 list(PREPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}/sycl")
0688 # Make the "VecMem language code" available for the whole project.
0689 include("${VECMEM_LANGUAGE_DIR}/vecmem-check-language.cmake")
0690 endif()
0691 # Make the "VecMem language code" available for the whole project.
0692 list(APPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}")
0693 endif()
0694
0695 if(ACTS_SETUP_COVFIE)
0696 if(ACTS_USE_SYSTEM_COVFIE)
0697 find_package(covfie ${_acts_covfie_version} REQUIRED CONFIG)
0698 else()
0699 add_subdirectory(thirdparty/covfie)
0700 endif()
0701 endif()
0702
0703 if(ACTS_SETUP_DETRAY)
0704 # Tell detray that it is built as a component of ACTS
0705 set(DETRAY_IS_ACTS_COMPONENT TRUE)
0706 add_subdirectory(Detray)
0707 endif()
0708
0709 if(ACTS_BUILD_TRACCC)
0710 add_subdirectory(Traccc)
0711 endif()
0712
0713 # examples dependencies
0714 if(ACTS_BUILD_EXAMPLES)
0715 set(THREADS_PREFER_PTHREAD_FLAG ON)
0716 find_package(Threads REQUIRED)
0717
0718 set(_acts_hepmc3_components "search")
0719 if(ACTS_BUILD_EXAMPLES_ROOT)
0720 list(APPEND _acts_hepmc3_components "rootIO")
0721 endif()
0722
0723 find_package(
0724 HepMC3
0725 ${_acts_hepmc3_version}
0726 REQUIRED
0727 CONFIG
0728 COMPONENTS ${_acts_hepmc3_components}
0729 )
0730
0731 # HepMC3 only introduced a proper HepMC3::HepMC3 target in 3.2.6
0732 if(${HEPMC3_VERSION} VERSION_LESS 3.2.6)
0733 add_library(HepMC3::HepMC3 SHARED IMPORTED)
0734 set_property(
0735 TARGET HepMC3::HepMC3
0736 PROPERTY IMPORTED_LOCATION "${HEPMC3_LIB}"
0737 )
0738 target_include_directories(
0739 HepMC3::HepMC3
0740 INTERFACE "${HEPMC3_INCLUDE_DIR}"
0741 )
0742 endif()
0743 if(ACTS_BUILD_EXAMPLES_ROOT)
0744 # for simplicity always request all potentially required components.
0745 find_package(
0746 ROOT
0747 ${_acts_root_version}
0748 REQUIRED
0749 CONFIG
0750 COMPONENTS Core Geom Graf GenVector Hist Tree TreePlayer
0751 )
0752 endif()
0753 if(ACTS_BUILD_EXAMPLES_FASTJET)
0754 find_package(FastJet ${_acts_fastjet_version} REQUIRED)
0755 endif()
0756 if(ACTS_BUILD_EXAMPLES_DD4HEP AND ACTS_BUILD_EXAMPLES_GEANT4)
0757 find_package(
0758 DD4hep
0759 ${_acts_dd4hep_version}
0760 REQUIRED
0761 CONFIG
0762 COMPONENTS DDCore DDG4 DDDetectors
0763 )
0764 elseif(ACTS_BUILD_EXAMPLES_DD4HEP)
0765 find_package(
0766 DD4hep
0767 ${_acts_dd4hep_version}
0768 REQUIRED
0769 CONFIG
0770 COMPONENTS DDCore DDDetectors
0771 )
0772 endif()
0773 if(ACTS_BUILD_EXAMPLES_PYTHIA8)
0774 find_package(Pythia8 ${_acts_pythia8_version} REQUIRED)
0775 endif()
0776 if(ACTS_SETUP_ANNOY OR ACTS_BUILD_EXAMPLES_HASHING)
0777 add_subdirectory(thirdparty/Annoy)
0778 endif()
0779 endif()
0780 # other dependencies
0781 if(ACTS_BUILD_DOCS)
0782 find_package(Doxygen ${_acts_doxygen_version} REQUIRED)
0783 endif()
0784
0785 acts_enable_static_analysis() # enable static analysis for the main code, after dependencies are set up
0786
0787 # core library, core plugins, and other components
0788 add_component(Core Core)
0789 add_component_if(Fatras Fatras ACTS_BUILD_FATRAS)
0790 add_component_if(Alignment Alignment ACTS_BUILD_ALIGNMENT)
0791 add_subdirectory(Plugins)
0792
0793 add_subdirectory_if(thirdparty/OpenDataDetector ACTS_BUILD_ODD)
0794
0795 # Examples
0796 add_subdirectory_if(Examples ACTS_BUILD_EXAMPLES)
0797
0798 # Python bindings
0799 add_subdirectory_if(Python ACTS_BUILD_PYTHON_BINDINGS)
0800
0801 # automated tests and benchmarks
0802 if(ACTS_BUILD_BENCHMARKS OR ACTS_BUILD_INTEGRATIONTESTS OR ACTS_BUILD_UNITTESTS)
0803 enable_testing() # must be set in the main CMakeLists.txt
0804 add_subdirectory(Tests)
0805 endif()
0806
0807 # documentation, adding unconditionally but will only set up docs build if configured
0808 add_subdirectory(docs)
0809
0810 # create cmake configuration files and environment setup script
0811 include(ActsCreatePackageConfig)
0812 include(ActsCreateSetup)
0813
0814 acts_print_auto_enabled_options()