From 1839385fa95f391f24fcb596c065d322d938b656 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Tue, 9 Jun 2026 10:51:37 +0200 Subject: [PATCH] build: Add optional in-build ACTS build --- CMakeLists.txt | 2 ++ cmake/MaybeBuildActs.cmake | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 cmake/MaybeBuildActs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a0aa9d6..9ceda04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,8 @@ SET( ${PROJECT_NAME}_VERSION_PATCH 0 ) SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" ) +include(cmake/MaybeBuildActs.cmake) + find_package(EDM4HEP REQUIRED) find_package(k4FWCore REQUIRED) find_package(Acts REQUIRED COMPONENTS Core PluginDD4hep) diff --git a/cmake/MaybeBuildActs.cmake b/cmake/MaybeBuildActs.cmake new file mode 100644 index 0000000..a87136c --- /dev/null +++ b/cmake/MaybeBuildActs.cmake @@ -0,0 +1,24 @@ +# The setup below allows optionally building ACTS directly with the k4ActsTracking build. +# This avoids having to run separate build and install steps, and also allows getting a +# combined compilation database out. +if(IS_DIRECTORY ${ACTS_SOURCE_DIR}) + message(STATUS "Using ACTS from: ${ACTS_SOURCE_DIR}") + + include(FetchContent) + + # Build configuration needed for k4ActsTracking. + set(ACTS_USE_SYSTEM_NLOHMANN_JSON ON CACHE BOOL "Use system json") + set(ACTS_BUILD_PLUGIN_JSON ON CACHE BOOL "Build json plugin") + set(ACTS_BUILD_PLUGIN_ROOT ON CACHE BOOL "Build root plugin") + set(ACTS_BUILD_PLUGIN_DD4HEP ON CACHE BOOL "Build dd4hep plugin") + + + set(FETCHCONTENT_SOURCE_DIR_ACTS "${ACTS_SOURCE_DIR}" CACHE PATH "") + + # This makes `find_package(Acts)` transparently defer to `FetchContent` + # to being the ACTS build in. + FetchContent_Declare(Acts + SYSTEM + OVERRIDE_FIND_PACKAGE + ) +endif()