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