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