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 3.4.0)
0341 set(_acts_podio_version 1.0.1) # will try this first
0342 set(_acts_podio_fallback_version 0.17.4) # if not found, will try this one
0343 set(_acts_doxygen_version 1.9.4)
0344 set(_acts_hepmc3_version 3.2.4)
0345 set(_acts_nlohmanjson_version 3.11.3)
0346 set(_acts_gbl_version 04.00.05)
0347 set(_acts_mille_version 01.01.01)
0348 set(_acts_mp2_version 05.01.05)
0349 set(_acts_onnxruntime_version 1.12.0)
0350 set(_acts_geomodel_version 6.8.0)
0351 set(_acts_root_version 6.28.04) # first version with C++20 support
0352 set(_acts_tbb_version 2020.1)
0353 set(_acts_pythia8_version 8.310)
0354 set(_acts_pybind11_version 3.0.1)
0355 set(_acts_traccc_version 1.4.0)
0356 set(_acts_covfie_version 0.15.2)
0357 set(_acts_vecmem_version 1.27.0)
0358 set(_acts_annoy_version 1.17.3)
0359 set(_acts_fastjet_version 3.4.1)
0360 set(_acts_arrow_version 21.0.0)
0361
0362 # Help with compiler flags discovery
0363 include(ActsFunctions)
0364
0365 # Include the sources for the external dependencies.
0366 include(ActsExternSources)
0367
0368 # required packages
0369 if(ACTS_SETUP_BOOST)
0370 # Enable both program_options and unit_test_framework to reduce complexity
0371 # Also Cuda tests seem to use program_options
0372 set(_acts_boost_components)
0373 if(
0374 ACTS_BUILD_ANALYSIS_APPS
0375 OR ACTS_BUILD_UNITTESTS
0376 OR ACTS_BUILD_INTEGRATIONTESTS
0377 OR ACTS_BUILD_BENCHMARKS
0378 )
0379 list(APPEND _acts_boost_components program_options unit_test_framework)
0380 endif()
0381
0382 # Only the Mille plugin needs process/filesystem, and neither is part of
0383 # every Boost installation (Boost.Process is a compiled library since Boost
0384 # 1.88). The plugin reports if the one it needs is missing.
0385 find_package(
0386 Boost
0387 ${_acts_boost_version}
0388 REQUIRED
0389 COMPONENTS ${_acts_boost_components}
0390 OPTIONAL_COMPONENTS process filesystem
0391 )
0392
0393 if(Boost_VERSION VERSION_EQUAL "1.85.0")
0394 set(_boost_version_severity WARNING)
0395 if(ACTS_BUILD_EXAMPLES)
0396 set(_boost_version_severity FATAL_ERROR)
0397 endif()
0398 message(
0399 ${_boost_version_severity}
0400 "Boost 1.85.0 is known to be broken (https://github.com/boostorg/container/issues/273). Please use a different version."
0401 )
0402 endif()
0403 endif()
0404
0405 if(ACTS_SETUP_EIGEN3)
0406 if(ACTS_USE_SYSTEM_EIGEN3)
0407 find_package(Eigen3 REQUIRED CONFIG)
0408
0409 if(DEFINED Eigen3_VERSION)
0410 if(Eigen3_VERSION VERSION_LESS _acts_eigen3_version)
0411 message(
0412 FATAL_ERROR
0413 "Eigen3 ${Eigen3_VERSION} is too old (need >= 3.4.0)"
0414 )
0415 endif()
0416 if(Eigen3_VERSION VERSION_GREATER_EQUAL 6.0.0)
0417 message(
0418 FATAL_ERROR
0419 "Eigen3 ${Eigen3_VERSION} is not supported (need < 6.0.0)"
0420 )
0421 endif()
0422 else()
0423 message(
0424 WARNING
0425 "Eigen3 version unknown - cannot verify version requirements"
0426 )
0427 endif()
0428 else()
0429 add_subdirectory(thirdparty/eigen3)
0430 endif()
0431 # get the first include path so we can nicely print where we get eigen from
0432 get_target_property(
0433 _eigen3_include_dirs
0434 Eigen3::Eigen
0435 INTERFACE_INCLUDE_DIRECTORIES
0436 )
0437 if(_eigen3_include_dirs)
0438 list(GET _eigen3_include_dirs 0 _eigen3_first_include_dir)
0439 endif()
0440
0441 message(
0442 STATUS
0443 "Found Eigen3 at: ${_eigen3_first_include_dir} (${Eigen3_VERSION})"
0444 )
0445 endif()
0446
0447 # CUDA settings are collected here in a macro, so that they can be reused by different plugins
0448 macro(enable_cuda)
0449 enable_language(CUDA)
0450 set(CMAKE_CUDA_STANDARD 20 CACHE STRING "CUDA C++ standard to use")
0451 set(CMAKE_CUDA_STANDARD_REQUIRED
0452 ON
0453 CACHE BOOL
0454 "Force the C++ standard requirement"
0455 )
0456 if(NOT CMAKE_CUDA_ARCHITECTURES)
0457 set(CMAKE_CUDA_ARCHITECTURES
0458 "75;80;86;90"
0459 CACHE STRING
0460 "CUDA architectures to generate code for"
0461 )
0462 endif()
0463 set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -G")
0464 set(CMAKE_CUDA_FLAGS
0465 "${CMAKE_CUDA_FLAGS} --extended-lambda --dopt=on --generate-line-info --expt-relaxed-constexpr"
0466 )
0467 endmacro()
0468
0469 # optional packages
0470 #
0471 # find packages explicitly for each component even if this means searching for
0472 # the same package twice. This avoids having complex if/else trees to sort out
0473 # when a particular package is actually needed.
0474
0475 # nlohmann_json has to be resolved before any other package, because its config
0476 # file defines a non-namespaced `nlohmann_json` compatibility target whenever it
0477 # is searched for without a version. That target clashes with the one the
0478 # bundled build creates, so we have to claim the name first.
0479 if(ACTS_BUILD_PLUGIN_JSON)
0480 if(ACTS_USE_SYSTEM_NLOHMANN_JSON)
0481 find_package(nlohmann_json ${_acts_nlohmanjson_version} REQUIRED CONFIG)
0482 else()
0483 add_subdirectory(thirdparty/nlohmann_json)
0484 endif()
0485 endif()
0486 if(ACTS_BUILD_PYTHON_BINDINGS)
0487 find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)
0488 if(ACTS_USE_SYSTEM_PYBIND11)
0489 find_package(pybind11 CONFIG REQUIRED)
0490 else()
0491 add_subdirectory(thirdparty/pybind11)
0492 endif()
0493 endif()
0494 # Set up ActSVG when explicitly requested via plugin build, or when Detray's
0495 # SVG display path is enabled in the superbuild.
0496 if(
0497 ACTS_BUILD_PLUGIN_ACTSVG
0498 OR (
0499 ACTS_SETUP_DETRAY
0500 AND (NOT DEFINED DETRAY_SVG_DISPLAY OR DETRAY_SVG_DISPLAY)
0501 )
0502 )
0503 if(ACTS_USE_SYSTEM_ACTSVG)
0504 find_package(actsvg ${_acts_actsvg_version} REQUIRED CONFIG)
0505 else()
0506 add_subdirectory(thirdparty/actsvg)
0507 endif()
0508 endif()
0509 if(ACTS_BUILD_PLUGIN_DD4HEP)
0510 # Explicitly find python so we can more easily override the version
0511 find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)
0512 find_package(
0513 DD4hep
0514 ${_acts_dd4hep_version}
0515 REQUIRED
0516 CONFIG
0517 COMPONENTS DDCore DDDetectors
0518 )
0519 endif()
0520 if(ACTS_BUILD_PLUGIN_GBL)
0521 if(ACTS_USE_SYSTEM_GBL)
0522 find_package(GBL ${_acts_gbl_version} REQUIRED CONFIG)
0523 else()
0524 add_subdirectory(thirdparty/GBL)
0525 endif()
0526 endif()
0527 if(ACTS_BUILD_PLUGIN_MILLE)
0528 if(ACTS_USE_SYSTEM_MILLE)
0529 find_package(Mille ${_acts_mille_version} REQUIRED CONFIG)
0530 else()
0531 add_subdirectory(thirdparty/Mille)
0532 endif()
0533 if(ACTS_USE_SYSTEM_MP2)
0534 find_package(millepedeII ${_acts_mp2_version} REQUIRED CONFIG)
0535 else()
0536 add_subdirectory(thirdparty/Millepede-II)
0537 endif()
0538 endif()
0539 if(ACTS_BUILD_PLUGIN_GEOMODEL)
0540 find_package(GeoModelCore CONFIG)
0541 if(NOT GeoModelCore_FOUND)
0542 message(
0543 FATAL_ERROR
0544 "GeoModel not found. Please install GeoModel or set ACTS_BUILD_PLUGIN_GEOMODEL to OFF."
0545 )
0546 endif()
0547
0548 if(GeoModelCore_VERSION VERSION_LESS _acts_geomodel_version)
0549 message(
0550 FATAL_ERROR
0551 "GeoModel version ${GeoModelCore_VERSION} is insufficient. Please install GeoModel version ${_acts_geomodel_version} or newer."
0552 )
0553 endif()
0554 # find other GeoModel components of EXACT same version
0555 find_package(GeoModelIO ${GeoModelCore_VERSION} REQUIRED EXACT CONFIG)
0556 endif()
0557 if(ACTS_BUILD_PLUGIN_ROOT)
0558 # In the ATLAS build, the ROOT find_package call does not find VDT unless these variables are set.
0559 # This should not affect other environments.
0560 find_package(VDT QUIET)
0561 if(VDT_FOUND)
0562 set(VDT_INCLUDE_DIR "${VDT_INCLUDE_DIR}" CACHE PATH "")
0563 set(VDT_LIBRARY "${VDT_vdt_LIBRARY}" CACHE FILEPATH "")
0564 endif()
0565
0566 find_package(
0567 ROOT
0568 ${_acts_root_version}
0569 REQUIRED
0570 CONFIG
0571 COMPONENTS Geom Graf Tree RIO Hist
0572 )
0573 endif()
0574 if(ACTS_BUILD_ANALYSIS_APPS)
0575 find_package(
0576 ROOT
0577 ${_acts_root_version}
0578 REQUIRED
0579 CONFIG
0580 COMPONENTS Geom Graf
0581 )
0582 endif()
0583 if(ACTS_ENABLE_CUDA)
0584 find_package(CUDAToolkit REQUIRED)
0585 enable_cuda()
0586 message(STATUS "Build ACTS with CUDA")
0587 endif()
0588 if(ACTS_BUILD_PLUGIN_GNN)
0589 if(ACTS_ENABLE_CUDA)
0590 message(STATUS "Build GNN plugin with CUDA")
0591 else()
0592 message(STATUS "Build GNN plugin for CPU only")
0593 endif()
0594 # FRNN and ModuleMapGraph are built from vendored upstream sources, which
0595 # are not ours to keep warning-clean. A normal variable, so it shadows the
0596 # cache entry for the subdirectories added below and is restored before any
0597 # ACTS target follows.
0598 set(_acts_gnn_warning_as_error "${CMAKE_COMPILE_WARNING_AS_ERROR}")
0599 set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
0600 if(ACTS_GNN_ENABLE_TORCH)
0601 find_package(Torch REQUIRED)
0602 if(ACTS_ENABLE_CUDA)
0603 add_subdirectory(thirdparty/FRNN)
0604 endif()
0605 endif()
0606 if(ACTS_GNN_ENABLE_MODULEMAP)
0607 if(ACTS_USE_SYSTEM_MODULEMAPGRAPH)
0608 find_package(ModuleMapGraph REQUIRED COMPONENTS CPU GPU)
0609 else()
0610 add_subdirectory(thirdparty/ModuleMapGraph)
0611 endif()
0612 endif()
0613 set(CMAKE_COMPILE_WARNING_AS_ERROR "${_acts_gnn_warning_as_error}")
0614 endif()
0615 if(ACTS_BUILD_PLUGIN_ONNX OR ACTS_GNN_ENABLE_ONNX)
0616 find_package(onnxruntime ${_acts_onnxruntime_version} MODULE REQUIRED)
0617 endif()
0618 if(ACTS_BUILD_PLUGIN_EDM4HEP)
0619 find_package(EDM4HEP ${_acts_edm4hep_version} CONFIG)
0620 if(NOT EDM4HEP_FOUND)
0621 message(
0622 STATUS
0623 "EDM4hep not found, trying version ${_acts_edm4hep_fallback_version}"
0624 )
0625 find_package(EDM4HEP ${_acts_edm4hep_fallback_version} CONFIG REQUIRED)
0626 endif()
0627 find_package(podio ${_acts_podio_version} CONFIG)
0628 if(NOT podio_FOUND)
0629 message(
0630 STATUS
0631 "Podio not found, trying ${_acts_podio_fallback_version} version"
0632 )
0633 find_package(podio ${_acts_podio_fallback_version} CONFIG REQUIRED)
0634 endif()
0635 find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Core)
0636 endif()
0637 if(ACTS_BUILD_PLUGIN_GEANT4)
0638 find_package(Geant4 ${_acts_geant4_version} REQUIRED CONFIG COMPONENTS gdml)
0639 endif()
0640 if(ACTS_BUILD_PLUGIN_ARROW)
0641 find_package(Arrow REQUIRED CONFIG)
0642 find_package(Parquet REQUIRED CONFIG)
0643 find_package(ArrowDataset REQUIRED CONFIG)
0644 # Arrow's package config requires an exact version match, so enforce our
0645 # minimum supported major version manually instead.
0646 string(REPLACE "." ";" _acts_arrow_version_list ${_acts_arrow_version})
0647 list(GET _acts_arrow_version_list 0 _acts_arrow_version_major)
0648 if(Arrow_VERSION_MAJOR LESS _acts_arrow_version_major)
0649 message(
0650 FATAL_ERROR
0651 "Found Arrow ${Arrow_VERSION}, but at least ${_acts_arrow_version} is required"
0652 )
0653 endif()
0654 endif()
0655
0656 if(ACTS_SETUP_VECMEM)
0657 if(ACTS_USE_SYSTEM_VECMEM)
0658 find_package(vecmem ${_acts_vecmem_version} REQUIRED)
0659 elseif(NOT TARGET vecmem::core)
0660 add_subdirectory(thirdparty/vecmem)
0661 list(PREPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}")
0662 list(PREPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}/sycl")
0663 # Make the "VecMem language code" available for the whole project.
0664 include("${VECMEM_LANGUAGE_DIR}/vecmem-check-language.cmake")
0665 endif()
0666 # Make the "VecMem language code" available for the whole project.
0667 list(APPEND CMAKE_MODULE_PATH "${VECMEM_LANGUAGE_DIR}")
0668 endif()
0669
0670 if(ACTS_SETUP_COVFIE)
0671 if(ACTS_USE_SYSTEM_COVFIE)
0672 find_package(covfie ${_acts_covfie_version} REQUIRED CONFIG)
0673 else()
0674 add_subdirectory(thirdparty/covfie)
0675 endif()
0676 endif()
0677
0678 if(ACTS_SETUP_DETRAY)
0679 # HACK: Temporary logic (aka technical debt) to make the detray component
0680 # work in traccc.
0681
0682 # Let ACTS set up all of the dependencies
0683 option(DETRAY_SETUP_VECMEM "" FALSE)
0684 option(DETRAY_SETUP_NLOHMANN "" FALSE)
0685 option(DETRAY_SETUP_EIGEN3 "" FALSE)
0686 option(DETRAY_SETUP_ACTSVG "" FALSE)
0687 option(DETRAY_SETUP_COVFIE "" FALSE)
0688 option(DETRAY_SETUP_PYBIND11 "" FALSE)
0689
0690 # Enable optional components depending on ACTS configuration
0691 set_option_if(DETRAY_BUILD_CUDA ACTS_ENABLE_CUDA)
0692 set_option_if(DETRAY_BUILD_UNIT_TESTS ACTS_BUILD_UNITTESTS)
0693 set_option_if(DETRAY_BUILD_INTEGRATION_TESTS ACTS_BUILD_INTEGRATIONTESTS)
0694 set_option_if(DETRAY_BUILD_BENCHMARKS ACTS_BUILD_BENCHMARKS)
0695 set_option_if(DETRAY_BUILD_TUTORIALS ACTS_BUILD_EXAMPLES)
0696 set_option_if(DETRAY_SVG_DISPLAY ACTS_BUILD_PLUGIN_ACTSVG)
0697
0698 # Enable dependencies of ACTS Detray plugin unit tests
0699 set_option_if(DETRAY_BUILD_TEST_UTILS ACTS_BUILD_EXAMPLES_UNITTESTS)
0700
0701 if(ACTS_BUILD_TRACCC)
0702 # Some detray validation tools are used in optional traccc libraries
0703 set_option_if(
0704 DETRAY_BUILD_VALIDATION_TOOLS
0705 TRACCC_BUILD_PERFORMANCE
0706 OR
0707 TRACCC_BUILD_TESTING
0708 )
0709
0710 set(DETRAY_GENERATE_METADATA
0711 "itk_metadata"
0712 CACHE STRING
0713 "Semicolon-separated list of metadata generator scripts to run in this build"
0714 )
0715 endif()
0716
0717 add_subdirectory(Detray)
0718 endif()
0719
0720 if(ACTS_BUILD_TRACCC)
0721 # HACK: Temporary logic (aka technical debt) to make the traccc
0722 # component work. Remove this ASAP.
0723 option(TRACCC_USE_ROOT "" FALSE)
0724 option(TRACCC_SETUP_ACTS "" FALSE)
0725 option(TRACCC_SETUP_VECMEM "" FALSE)
0726 option(TRACCC_SETUP_EIGEN3 "" FALSE)
0727 option(TRACCC_SETUP_THRUST "" TRUE)
0728 option(TRACCC_SETUP_COVFIE "" FALSE)
0729 option(TRACCC_SETUP_DETRAY "" FALSE)
0730 option(TRACCC_BUILD_CUDA "" ${ACTS_ENABLE_CUDA})
0731 option(TRACCC_SETUP_TBB "" FALSE)
0732 option(TRACCC_BUILD_IO "" TRUE)
0733 option(TRACCC_BUILD_PERFORMANCE "" FALSE)
0734 option(TRACCC_BUILD_SIMULATION "" FALSE)
0735 option(TRACCC_BUILD_TESTING "" FALSE)
0736 option(TRACCC_BUILD_EXAMPLES "" FALSE)
0737 option(TRACCC_BUILD_BENCHMARKS "" FALSE)
0738
0739 find_package(TBB ${_acts_tbb_version} CONFIG)
0740 if(NOT TBB_FOUND)
0741 set(TRACCC_SETUP_TBB TRUE CACHE BOOL "")
0742 else()
0743 set(TRACCC_SETUP_TBB FALSE CACHE BOOL "")
0744 endif()
0745
0746 add_subdirectory(Traccc)
0747 endif()
0748
0749 # examples dependencies
0750 if(ACTS_BUILD_EXAMPLES)
0751 set(THREADS_PREFER_PTHREAD_FLAG ON)
0752 find_package(Threads REQUIRED)
0753
0754 set(_acts_hepmc3_components "search")
0755 if(ACTS_BUILD_EXAMPLES_ROOT)
0756 list(APPEND _acts_hepmc3_components "rootIO")
0757 endif()
0758
0759 find_package(
0760 HepMC3
0761 ${_acts_hepmc3_version}
0762 REQUIRED
0763 CONFIG
0764 COMPONENTS ${_acts_hepmc3_components}
0765 )
0766
0767 # HepMC3 only introduced a proper HepMC3::HepMC3 target in 3.2.6
0768 if(${HEPMC3_VERSION} VERSION_LESS 3.2.6)
0769 add_library(HepMC3::HepMC3 SHARED IMPORTED)
0770 set_property(
0771 TARGET HepMC3::HepMC3
0772 PROPERTY IMPORTED_LOCATION "${HEPMC3_LIB}"
0773 )
0774 target_include_directories(
0775 HepMC3::HepMC3
0776 INTERFACE "${HEPMC3_INCLUDE_DIR}"
0777 )
0778 endif()
0779 if(ACTS_BUILD_EXAMPLES_ROOT)
0780 # for simplicity always request all potentially required components.
0781 find_package(
0782 ROOT
0783 ${_acts_root_version}
0784 REQUIRED
0785 CONFIG
0786 COMPONENTS Core Geom Graf GenVector Hist Tree TreePlayer
0787 )
0788 endif()
0789 if(ACTS_BUILD_EXAMPLES_FASTJET)
0790 find_package(FastJet ${_acts_fastjet_version} REQUIRED)
0791 endif()
0792 if(ACTS_BUILD_EXAMPLES_DD4HEP AND ACTS_BUILD_EXAMPLES_GEANT4)
0793 find_package(
0794 DD4hep
0795 ${_acts_dd4hep_version}
0796 REQUIRED
0797 CONFIG
0798 COMPONENTS DDCore DDG4 DDDetectors
0799 )
0800 elseif(ACTS_BUILD_EXAMPLES_DD4HEP)
0801 find_package(
0802 DD4hep
0803 ${_acts_dd4hep_version}
0804 REQUIRED
0805 CONFIG
0806 COMPONENTS DDCore DDDetectors
0807 )
0808 endif()
0809 if(ACTS_BUILD_EXAMPLES_PYTHIA8)
0810 find_package(Pythia8 ${_acts_pythia8_version} REQUIRED)
0811 endif()
0812 if(ACTS_SETUP_ANNOY OR ACTS_BUILD_EXAMPLES_HASHING)
0813 add_subdirectory(thirdparty/Annoy)
0814 endif()
0815 endif()
0816 # other dependencies
0817 if(ACTS_BUILD_DOCS)
0818 find_package(Doxygen ${_acts_doxygen_version} REQUIRED)
0819 endif()
0820
0821 acts_enable_static_analysis() # enable static analysis for the main code, after dependencies are set up
0822
0823 # core library, core plugins, and other components
0824 add_component(Core Core)
0825 add_component_if(Fatras Fatras ACTS_BUILD_FATRAS)
0826 add_component_if(Alignment Alignment ACTS_BUILD_ALIGNMENT)
0827 add_subdirectory(Plugins)
0828
0829 add_subdirectory_if(thirdparty/OpenDataDetector ACTS_BUILD_ODD)
0830
0831 # Examples
0832 add_subdirectory_if(Examples ACTS_BUILD_EXAMPLES)
0833
0834 # Python bindings
0835 add_subdirectory_if(Python ACTS_BUILD_PYTHON_BINDINGS)
0836
0837 # automated tests and benchmarks
0838 if(ACTS_BUILD_BENCHMARKS OR ACTS_BUILD_INTEGRATIONTESTS OR ACTS_BUILD_UNITTESTS)
0839 enable_testing() # must be set in the main CMakeLists.txt
0840 add_subdirectory(Tests)
0841 endif()
0842
0843 # documentation, adding unconditionally but will only set up docs build if configured
0844 add_subdirectory(docs)
0845
0846 # create cmake configuration files and environment setup script
0847 include(ActsCreatePackageConfig)
0848 include(ActsCreateSetup)