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