Back to home page

EIC code displayed by LXR

 
 

    


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