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