Warning, /acts/Detray/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008
0009 # Set up the project.
0010 cmake_minimum_required(VERSION 3.21)
0011 project(detray VERSION 0.111.0 LANGUAGES CXX)
0012
0013 # Set up the used C++ standard(s).
0014 set(CMAKE_CXX_STANDARD 20 CACHE STRING "The (host) C++ standard to use")
0015 set(CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable (host) C++ extensions")
0016 set(CMAKE_CUDA_STANDARD 20 CACHE STRING "The (CUDA) C++ standard to use")
0017 set(CMAKE_CUDA_EXTENSIONS FALSE CACHE BOOL "Disable (CUDA) C++ extensions")
0018 set(CMAKE_SYCL_STANDARD 20 CACHE STRING "The (SYCL) C++ standard to use")
0019 set(CMAKE_HIP_STANDARD 20 CACHE STRING "The (HIP) C++ standard to use")
0020 set(CMAKE_HIP_EXTENSIONS FALSE CACHE BOOL "Disable (HIP) C++ extensions")
0021
0022 if(PROJECT_IS_TOP_LEVEL)
0023 if(${CMAKE_CXX_STANDARD} LESS 20)
0024 message(
0025 SEND_ERROR
0026 "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}, but detray requires C++>=20"
0027 )
0028 endif()
0029 endif()
0030
0031 # Explicitly set the output directory for the binaries. Such that if this
0032 # project is included by another project, the main project's configuration would
0033 # win out.
0034 include(GNUInstallDirs)
0035
0036 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
0037 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}"
0038 CACHE PATH
0039 "Directory for the built binaries"
0040 )
0041 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
0042 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
0043 CACHE PATH
0044 "Directory for the built libraries"
0045 )
0046 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
0047 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
0048 CACHE PATH
0049 "Directory for the built static libraries"
0050 )
0051
0052 set(DETRAY_PYTHON_INSTALL_DIR "python/detray")
0053
0054 # Include the Detray CMake code.
0055 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
0056 include(detray-functions)
0057
0058 #
0059 # Define build options
0060 #
0061 include(CMakeDependentOption)
0062
0063 # General
0064 option(DETRAY_USE_SYSTEM_LIBS "Use system libraries be default" FALSE)
0065 option(
0066 DETRAY_FAIL_ON_WARNINGS
0067 "Make the build fail on compiler/linker warnings"
0068 FALSE
0069 )
0070 set(DETRAY_SET_LOGGING "INFO" CACHE STRING "Set the log level")
0071 set_property(
0072 CACHE DETRAY_SET_LOGGING
0073 PROPERTY STRINGS "NONE" "WARNING" "INFO" "VERBOSE" "DEBUG"
0074 )
0075 option(DETRAY_BUILD_CLI_TOOLS "Build the command line tools of Detray" OFF)
0076 # Which detector metadata headers to generate during the build
0077 set(DETRAY_GENERATE_METADATA
0078 ""
0079 CACHE STRING
0080 "Semicolon-separated list of metadata generator scripts to run in this build"
0081 )
0082
0083 # Device compilation
0084
0085 # Check if CUDA is available.
0086 include(CheckLanguage)
0087 check_language(CUDA)
0088 option(
0089 DETRAY_BUILD_CUDA
0090 "Build the CUDA sources included in detray"
0091 ${CMAKE_CUDA_COMPILER}
0092 )
0093
0094 option(DETRAY_BUILD_SYCL "Build the SYCL sources included in detray" OFF)
0095
0096 # Check if HIP is available
0097 option(DETRAY_BUILD_HIP "Build the HIP sources included in detray" OFF)
0098
0099 cmake_dependent_option(
0100 DETRAY_BUILD_HOST
0101 "Build the host sources included in detray"
0102 ON
0103 "DETRAY_BUILD_CUDA OR DETRAY_BUILD_SYCL OR DETRAY_BUILD_HIP"
0104 ON
0105 )
0106
0107 # Plugins / Algebra backends
0108 option(DETRAY_SVG_DISPLAY "Build ActSVG display module" OFF)
0109 option(DETRAY_ARRAY_PLUGIN "Build Eigen math plugin" ON)
0110 option(DETRAY_EIGEN_PLUGIN "Build Eigen math plugin" OFF)
0111 option(DETRAY_FASTOR_PLUGIN "Build Fastor math plugin" OFF)
0112 option(DETRAY_SMATRIX_PLUGIN "Build ROOT/SMatrix math plugin" OFF)
0113 option(DETRAY_VC_AOS_PLUGIN "Build Vc based AoS math plugin" OFF)
0114 option(DETRAY_VC_SOA_PLUGIN "Build Vc based SoA math plugin" OFF)
0115
0116 # Test and benchmark suite
0117 include(CTest)
0118
0119 option(DETRAY_BUILD_ALL_TESTS "Build unit and integrations tests of Detray" OFF)
0120 option(DETRAY_BUILD_UNITTESTS "Build the unit tests of Detray" OFF)
0121 option(
0122 DETRAY_BUILD_INTEGRATIONTESTS
0123 "Build the integration tests of Detray"
0124 OFF
0125 )
0126 option(DETRAY_BUILD_TEST_UTILS "Build the test utility library of Detray" OFF)
0127 option(DETRAY_BUILD_VALIDATION_TOOLS "Build the validation tools of Detray" OFF)
0128 option(DETRAY_BUILD_BENCHMARKS "Build the benchmark tests" OFF)
0129 option(DETRAY_BUILD_TUTORIALS "Build the tutorial executables of Detray" OFF)
0130
0131 #
0132 # Resolve build options and option inter-dependencies
0133 #
0134
0135 # Set the internal log level from user input
0136 set(DETRAY_LOG_LVL -1 CACHE INTERNAL "Disable logging")
0137 if(DETRAY_SET_LOGGING STREQUAL "WARN")
0138 set(DETRAY_LOG_LVL 0 CACHE INTERNAL "Print warnings and errors" FORCE)
0139 elseif(DETRAY_SET_LOGGING STREQUAL "INFO")
0140 set(DETRAY_LOG_LVL 1 CACHE INTERNAL "Print general information" FORCE)
0141 elseif(DETRAY_SET_LOGGING STREQUAL "VERBOSE")
0142 set(DETRAY_LOG_LVL 2 CACHE INTERNAL "Print detailed information" FORCE)
0143 elseif(DETRAY_SET_LOGGING STREQUAL "DEBUG")
0144 set(DETRAY_LOG_LVL 3 CACHE INTERNAL "Print expert information" FORCE)
0145 endif()
0146
0147 # Need test utils in CLI tools for the example detector generation
0148 if(DETRAY_BUILD_CLI_TOOLS)
0149 set(DETRAY_BUILD_TEST_UTILS ON)
0150 endif()
0151
0152 # Check CUDA and SYCL and HIP C++ standards
0153 if(${DETRAY_BUILD_CUDA} AND ${CMAKE_CUDA_STANDARD} LESS 20)
0154 message(
0155 SEND_ERROR
0156 "CMAKE_CUDA_STANDARD=${CMAKE_CUDA_STANDARD}, but detray requires C++>=20"
0157 )
0158 endif()
0159
0160 if(${DETRAY_BUILD_SYCL} AND ${CMAKE_SYCL_STANDARD} LESS 20)
0161 message(
0162 SEND_ERROR
0163 "CMAKE_SYCL_STANDARD=${CMAKE_SYCL_STANDARD}, but detray requires C++>=20"
0164 )
0165 endif()
0166
0167 if(${DETRAY_BUILD_HIP} AND ${CMAKE_HIP_STANDARD} LESS 20)
0168 message(
0169 SEND_ERROR
0170 "CMAKE_HIP_STANDARD=${CMAKE_HIP_STANDARD}, but detray requires C++>=20"
0171 )
0172 endif()
0173
0174 # Disable the [[no_unique_address]] annotation if we are on CUDA>=13.0.
0175 # TODO: Update this statement once a fix in CUDA is available.
0176 set(DETRAY_INTERNAL_USE_NO_UNIQUE_ADDRESS_ANNOTATION ON)
0177
0178 if(DETRAY_BUILD_CUDA)
0179 # Figure out the version of CUDA being used.
0180 find_package(CUDAToolkit REQUIRED)
0181
0182 if(CUDAToolkit_VERSION_MAJOR GREATER_EQUAL 13)
0183 message(
0184 STATUS
0185 "Disabling [[no_unique_address]] annotation due to CUDA incompatibility"
0186 )
0187 set(DETRAY_INTERNAL_USE_NO_UNIQUE_ADDRESS_ANNOTATION OFF)
0188 endif()
0189 endif()
0190
0191 # Convenience option to build tests
0192 if(DETRAY_BUILD_ALL_TESTS)
0193 set(DETRAY_BUILD_UNITTESTS ON)
0194 set(DETRAY_BUILD_INTEGRATIONTESTS ON)
0195 endif()
0196
0197 # Alias flag to enable tests in detray (pulls in google test and triggers the build of executables that depend on it)
0198 if(BUILD_TESTING AND (DETRAY_BUILD_UNITTESTS OR DETRAY_BUILD_INTEGRATIONTESTS))
0199 set(DETRAY_BUILD_TESTING ON)
0200 endif()
0201
0202 # Validation utilities are needed for integration tests and tutorials
0203 if(DETRAY_BUILD_TESTING OR DETRAY_BUILD_TUTORIALS)
0204 set(DETRAY_BUILD_VALIDATION_TOOLS ON)
0205 endif()
0206
0207 # Test utilities are needed for validation utilities
0208 if(DETRAY_BUILD_TESTING OR DETRAY_BUILD_VALIDATION_TOOLS)
0209 set(DETRAY_BUILD_TEST_UTILS ON)
0210 endif()
0211
0212 # Svg display is needed for the validation utilities
0213 if(DETRAY_BUILD_VALIDATION_TOOLS)
0214 set(DETRAY_SVG_DISPLAY ON)
0215 endif()
0216
0217 # Allow the compilation of test with code sanitizers
0218 cmake_dependent_option(
0219 DETRAY_ENABLE_SANITIZER
0220 "Compile tests with sanitizers"
0221 OFF
0222 "BUILD_TESTING AND DETRAY_BUILD_TESTING"
0223 OFF
0224 )
0225
0226 #
0227 # Configure dependencies
0228 #
0229
0230 # Set up VecMem.
0231 option(DETRAY_SETUP_VECMEM "Set up the VecMem target(s) explicitly" TRUE)
0232 option(
0233 DETRAY_USE_SYSTEM_VECMEM
0234 "Pick up an existing installation of VecMem from the build environment"
0235 ${DETRAY_USE_SYSTEM_LIBS}
0236 )
0237 if(DETRAY_SETUP_VECMEM)
0238 set(DETRAY_VECMEM_VERSION 1.23.0)
0239 set(DETRAY_VECMEM_DIGEST
0240 c4b87f88856b5273b89373d880bdc0fd
0241 CACHE STRING
0242 "MD5 digest of the downloaded zip"
0243 )
0244
0245 if(DETRAY_USE_SYSTEM_VECMEM)
0246 find_package(vecmem ${DETRAY_VECMEM_VERSION} REQUIRED)
0247 else()
0248 add_subdirectory(extern/vecmem)
0249 # Make the "VecMem language code" available for the whole project.
0250 include("${VECMEM_LANGUAGE_DIR}/vecmem-check-language.cmake")
0251 endif()
0252 endif()
0253
0254 include(vecmem-check-language)
0255
0256 # Set up JSON for I/O
0257 option(
0258 DETRAY_SETUP_NLOHMANN
0259 "Set up the nlohmann::json target(s) explicitly"
0260 TRUE
0261 )
0262 option(
0263 DETRAY_USE_SYSTEM_NLOHMANN
0264 "Pick up an existing installation of nlohman::json from the build environment"
0265 ${DETRAY_USE_SYSTEM_LIBS}
0266 )
0267 if(DETRAY_SETUP_NLOHMANN)
0268 set(DETRAY_NLOHMANN_VERSION 3.11.3)
0269 set(DETRAY_NLOHMANN_DIGEST
0270 2074caa675f8097d9b03c0f4976ffc3410170937
0271 CACHE STRING
0272 "SHA1 digest of the downloaded zip"
0273 )
0274
0275 if(DETRAY_USE_SYSTEM_NLOHMANN)
0276 find_package(nlohmann_json ${DETRAY_NLOHMANN_VERSION} REQUIRED)
0277 else()
0278 add_subdirectory(extern/nlohmann_json)
0279 endif()
0280 endif()
0281
0282 # Set up Eigen3.
0283 option(
0284 DETRAY_SETUP_EIGEN3
0285 "Set up the Eigen3 target(s) explicitly"
0286 ${DETRAY_EIGEN_PLUGIN}
0287 )
0288 option(
0289 DETRAY_USE_SYSTEM_EIGEN3
0290 "Pick up an existing installation of Eigen3 from the build environment"
0291 ${DETRAY_USE_SYSTEM_LIBS}
0292 )
0293 if(DETRAY_SETUP_EIGEN3)
0294 set(DETRAY_EIGEN_VERSION 3.4.0)
0295 set(DETRAY_EIGEN_DIGEST
0296 132dde48fe2b563211675626d29f1707
0297 CACHE STRING
0298 "MD5 digest of the downloaded zip"
0299 )
0300
0301 if(DETRAY_USE_SYSTEM_EIGEN3)
0302 find_package(Eigen3 REQUIRED)
0303 else()
0304 add_subdirectory(extern/eigen3)
0305 endif()
0306 endif()
0307
0308 # Set up Fastor.
0309 option(
0310 DETRAY_SETUP_FASTOR
0311 "Set up the Fastor target(s) explicitly"
0312 ${DETRAY_FASTOR_PLUGIN}
0313 )
0314 option(
0315 DETRAY_USE_SYSTEM_FASTOR
0316 "Pick up an existing installation of Fastor from the build environment"
0317 ${DETRAY_USE_SYSTEM_LIBS}
0318 )
0319 if(DETRAY_SETUP_FASTOR)
0320 set(DETRAY_FASTOR_VERSION 0.6.4)
0321 set(DETRAY_FASTOR_DIGEST
0322 0644a0bf6337e0ffc9e0173be757aa45
0323 CACHE STRING
0324 "MD5 digest of the downloaded zip"
0325 )
0326
0327 if(DETRAY_USE_SYSTEM_FASTOR)
0328 find_package(Fastor ${DETRAY_FASTOR_VERSION} REQUIRED)
0329 else()
0330 add_subdirectory(extern/fastor)
0331 endif()
0332 endif()
0333
0334 # Set up Vc.
0335 if(DETRAY_VC_SOA_PLUGIN)
0336 set(DETRAY_VC_AOS_PLUGIN ON)
0337 endif()
0338
0339 if(DETRAY_VC_AOS_PLUGIN)
0340 set(DETRAY_VC_PLUGIN ON)
0341 endif()
0342
0343 option(DETRAY_SETUP_VC "Set up the Vc target(s) explicitly" ${DETRAY_VC_PLUGIN})
0344 option(
0345 DETRAY_USE_SYSTEM_VC
0346 "Pick up an existing installation of Vc from the build environment"
0347 ${DETRAY_USE_SYSTEM_LIBS}
0348 )
0349 if(DETRAY_SETUP_VC)
0350 set(DETRAY_VC_VERSION 1.4.5)
0351 set(DETRAY_VC_DIGEST
0352 03831cbf0921a10322d8baf08001cbf5
0353 CACHE STRING
0354 "MD5 digest of the downloaded zip"
0355 )
0356
0357 if(DETRAY_USE_SYSTEM_VC)
0358 find_package(Vc ${DETRAY_VC_VERSION} REQUIRED)
0359 else()
0360 add_subdirectory(extern/vc)
0361 endif()
0362 endif()
0363
0364 # Set up ACTSVG for displaying
0365 option(
0366 DETRAY_SETUP_ACTSVG
0367 "Set up the actsvg target(s) explicitly"
0368 ${DETRAY_SVG_DISPLAY}
0369 )
0370 option(
0371 DETRAY_USE_SYSTEM_ACTSVG
0372 "Pick up an existing installation of actsvg from the build environment"
0373 ${DETRAY_USE_SYSTEM_LIBS}
0374 )
0375 if(DETRAY_SETUP_ACTSVG)
0376 set(DETRAY_ACTSVG_VERSION 0.4.57)
0377 set(DETRAY_ACTSVG_DIGEST
0378 5136e50ff2d78f0b1ff83a56be6a1954
0379 CACHE STRING
0380 "MD5 digest of the downloaded zip"
0381 )
0382
0383 if(DETRAY_USE_SYSTEM_ACTSVG)
0384 find_package(
0385 actsvg
0386 ${DETRAY_ACTSVG_VERSION}
0387 REQUIRED
0388 COMPONENTS core meta
0389 )
0390 else()
0391 add_subdirectory(extern/actsvg)
0392 endif()
0393 endif()
0394
0395 # Set up GoogleTest.
0396 option(
0397 DETRAY_SETUP_GOOGLETEST
0398 "Set up the GoogleTest target(s) explicitly"
0399 ${DETRAY_BUILD_TESTING}
0400 )
0401 option(
0402 DETRAY_USE_SYSTEM_GOOGLETEST
0403 "Pick up an existing installation of GoogleTest from the build environment"
0404 ${DETRAY_USE_SYSTEM_LIBS}
0405 )
0406 if(DETRAY_SETUP_GOOGLETEST)
0407 set(DETRAY_GOOGLETEST_VERSION 1.17.0)
0408 set(DETRAY_GOOGLETEST_DIGEST
0409 b6f100bc2a5853a48046aa168ececf84
0410 CACHE STRING
0411 "MD5 digest of the downloaded zip"
0412 )
0413
0414 if(DETRAY_USE_SYSTEM_GOOGLETEST)
0415 find_package(GTest REQUIRED)
0416 else()
0417 add_subdirectory(extern/googletest)
0418 endif()
0419 endif()
0420
0421 # Set up Google Benchmark.
0422 option(
0423 DETRAY_SETUP_BENCHMARK
0424 "Set up the Google Benchmark target(s) explicitly"
0425 ${DETRAY_BUILD_BENCHMARKS}
0426 )
0427 option(
0428 DETRAY_USE_SYSTEM_BENCHMARK
0429 "Pick up an existing installation of Google Benchmark from the build environment"
0430 ${DETRAY_USE_SYSTEM_LIBS}
0431 )
0432 if(DETRAY_SETUP_BENCHMARK)
0433 set(DETRAY_BENCHMARK_VERSION 1.9.5)
0434 set(DETRAY_BENCHMARK_DIGEST
0435 12c6c0c228fc07106c62634222bd2541
0436 CACHE STRING
0437 "MD5 digest of the downloaded zip"
0438 )
0439
0440 if(DETRAY_USE_SYSTEM_BENCHMARK)
0441 find_package(benchmark ${DETRAY_BENCHMARK_VERSION} REQUIRED)
0442 else()
0443 add_subdirectory(extern/benchmark)
0444 endif()
0445 endif()
0446
0447 # Set up covfie.
0448 if(DETRAY_BUILD_TESTING OR DETRAY_BUILD_BENCHMARKS OR DETRAY_BUILD_CLI_TOOLS)
0449 set(DETRAY_BUILD_COVFIE ON)
0450 endif()
0451 option(
0452 DETRAY_SETUP_COVFIE
0453 "Set up the covfie target(s) explicitly"
0454 ${DETRAY_BUILD_COVFIE}
0455 )
0456 option(
0457 DETRAY_USE_SYSTEM_COVFIE
0458 "Pick up an existing installation of covfie from the build environment"
0459 ${DETRAY_USE_SYSTEM_LIBS}
0460 )
0461 if(DETRAY_SETUP_COVFIE)
0462 set(DETRAY_COVFIE_VERSION 0.15.4)
0463 set(DETRAY_COVFIE_DIGEST
0464 80de9b43644c59d8239fb8cc184c6276
0465 CACHE STRING
0466 "MD5 digest of the downloaded zip"
0467 )
0468
0469 if(DETRAY_USE_SYSTEM_COVFIE)
0470 find_package(covfie ${DETRAY_COVFIE_VERSION} REQUIRED)
0471 else()
0472 add_subdirectory(extern/covfie)
0473 endif()
0474 endif()
0475
0476 #
0477 # Set up all of the libraries of the project.
0478 #
0479
0480 add_subdirectory(core)
0481 add_subdirectory(detectors)
0482 add_subdirectory(io)
0483 add_subdirectory(plugins)
0484 add_subdirectory(python)
0485
0486 # Test utils and validation tools can also be required standalone
0487 # (e.g. in ACTS detray plugin)
0488 if(
0489 DETRAY_BUILD_TESTING
0490 OR DETRAY_BUILD_TEST_UTILS
0491 OR DETRAY_BUILD_VALIDATION_TOOLS
0492 OR DETRAY_BUILD_BENCHMARKS
0493 OR DETRAY_BUILD_CLI_TOOLS
0494 )
0495 add_subdirectory(tests)
0496 endif()
0497
0498 # Set up the tutorial(s).
0499 if(DETRAY_BUILD_TUTORIALS)
0500 add_subdirectory(tutorials)
0501 endif()
0502
0503 # Set up the packaging of the project.
0504 include(detray-packaging)