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