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