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