gaudi: Specify boost dependencies explicitly and cleanup package (#46194)

* gaudi: Specify boost components and add +fiber for v39

* gaudi: Limit fmt version to allow building master branch

* Make boost dependencies a bit more readable

* Remove patches for no longer existing versions
This commit is contained in:
Thomas Madlener 2024-09-05 16:27:04 +02:00 committed by GitHub
parent 02faa7b97e
commit 5d9f0cf44e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 239 deletions

View File

@ -1,13 +0,0 @@
diff --git a/GaudiExamples/CMakeLists.txt b/GaudiExamples/CMakeLists.txt
index ef6f9fcff..672b76d26 100644
--- a/GaudiExamples/CMakeLists.txt
+++ b/GaudiExamples/CMakeLists.txt
@@ -0,0 +1,7 @@
+# GaudiExamples subdirectory
+if(NOT BUILD_TESTING)
+ # Ignore examples if not building tests
+ # see https://gitlab.cern.ch/atlas/atlasexternals/-/merge_requests/664#note_3395313
+ return()
+endif()
+

View File

@ -1,106 +0,0 @@
diff --git a/cmake/GaudiProjectConfig.cmake b/cmake/GaudiProjectConfig.cmake
index d7049233e..a9ef71e9a 100644
--- a/cmake/GaudiProjectConfig.cmake
+++ b/cmake/GaudiProjectConfig.cmake
@@ -356,6 +356,8 @@ macro(gaudi_project project version)
# Make sure we select the version of Python provided by LCG (if we are building in that context)
if(Python_config_version)
set(Python_config_version ${Python_config_version} CACHE STRING "LCG version of Python")
+ # Prevent special LCG versions (like 2.7.9.p1) to confuse CMake
+ string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" Python_config_version "${Python_config_version}")
find_package(PythonInterp ${Python_config_version} QUIET)
find_package(PythonLibs ${Python_config_version} QUIET)
if(CMAKE_VERSION VERSION_GREATER 3.12)
@@ -373,10 +375,10 @@ macro(gaudi_project project version)
#-- Set up the boost_python_version variable for the project
find_package(PythonInterp)
find_package(Boost)
- if((Boost_VERSION GREATER 106700) OR (Boost_VERSION EQUAL 106700))
- set(boost_python_version "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
+ if((Boost_VERSION LESS 106700) OR (Boost_VERSION GREATER 1069000))
+ set(boost_python_version "")
else()
- set(boost_python_version "")
+ set(boost_python_version "${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
endif()
#--- Allow installation on failed builds
@@ -1620,9 +1622,24 @@ function(gaudi_resolve_link_libraries variable)
set(collected)
foreach(package ${ARGN})
# check if it is an actual library or a target first
+ if(NOT TARGET ${package})
+ if(package MATCHES "^Boost::(.*)$")
+ # special handling of Boost imported targets
+ find_package(Boost COMPONENTS ${CMAKE_MATCH_1} QUIET)
+ else()
+ # the target might be in a project namespace
+ foreach(_p IN LISTS used_gaudi_projects)
+ if(TARGET ${_p}::${package})
+ #message(STATUS "using ${_p}::${package} for ${package}")
+ set(package ${_p}::${package})
+ break()
+ endif()
+ endforeach()
+ endif()
+ endif()
if(TARGET ${package})
get_property(target_type TARGET ${package} PROPERTY TYPE)
- if(NOT target_type MATCHES "(SHARED|STATIC)_LIBRARY")
+ if(NOT target_type MATCHES "(SHARED|STATIC|UNKNOWN)_LIBRARY")
message(FATAL_ERROR "${package} is a ${target_type}: you cannot link against it")
endif()
#message(STATUS "${package} is a TARGET")
@@ -1670,6 +1687,19 @@ function(gaudi_resolve_link_libraries variable)
endforeach()
#message(STATUS "gaudi_resolve_link_libraries collected: ${collected}")
_gaudi_strip_build_type_libs(collected)
+ # resolve missing Boost::* targets, if needed
+ set(boost_components ${collected})
+ list(FILTER boost_components INCLUDE REGEX "^Boost::")
+ list(TRANSFORM boost_components REPLACE "^Boost::" "")
+ set(missing_components)
+ foreach(comp IN LISTS boost_components)
+ if(NOT TARGET Boost::${comp})
+ list(APPEND missing_components ${comp})
+ endif()
+ endforeach()
+ if(missing_components)
+ find_package(Boost COMPONENTS ${missing_components} QUIET)
+ endif()
#message(STATUS "gaudi_resolve_link_libraries output: ${collected}")
set(${variable} ${collected} PARENT_SCOPE)
endfunction()
@@ -3277,6 +3307,14 @@ macro(gaudi_external_project_environment)
list(FIND used_gaudi_projects ${pack} gaudi_project_idx)
if((NOT pack STREQUAL GaudiProject) AND (gaudi_project_idx EQUAL -1))
message(STATUS " ${pack}")
+ if(pack STREQUAL Boost)
+ if(NOT TARGET Boost::headers)
+ # this is needed to get the non-cache variables for the packages
+ # but we do not need to call it if we do not use FindBoost.cmake (Boost >= 1.70)
+ find_package(${pack} QUIET)
+ endif()
+ endif()
+
if(NOT pack MATCHES "^Python(Interp|Libs)?$")
# this is needed to get the non-cache variables for the packages
find_package(${pack} QUIET)
@@ -3325,6 +3363,17 @@ macro(gaudi_external_project_environment)
list(APPEND environment SET QT_XKB_CONFIG_ROOT "/usr/share/X11/xkb")
endif()
endif()
+ elseif(pack MATCHES "^boost_(.*)$")
+ # We are using BoostConfig.cmake (>=1.70) and not FindBoost.cmake
+ if(TARGET "Boost::${CMAKE_MATCH_1}")
+ set(tgt_name "Boost::${CMAKE_MATCH_1}")
+ get_property(target_type TARGET ${tgt_name} PROPERTY TYPE)
+ if(target_type MATCHES "(SHARED|UNKNOWN)_LIBRARY")
+ # FIXME: I'm not sure it's good to rely on the "_RELEASE" suffix
+ get_property(lib_path TARGET ${tgt_name} PROPERTY IMPORTED_LOCATION_RELEASE)
+ get_filename_component(${pack}_LIBRARY_DIR "${lib_path}" PATH)
+ endif()
+ endif()
endif()
list(APPEND binary_path ${${pack}_BINARY_PATH})

View File

@ -1,107 +0,0 @@
diff --git a/cmake/GaudiProjectConfig.cmake b/cmake/GaudiProjectConfig.cmake
index 3da52a9c6..08c11c863 100644
--- a/cmake/GaudiProjectConfig.cmake
+++ b/cmake/GaudiProjectConfig.cmake
@@ -346,6 +346,8 @@ macro(gaudi_project project version)
# Make sure we select the version of Python provided by LCG (if we are building in that context)
if(Python_config_version)
set(Python_config_version ${Python_config_version} CACHE STRING "LCG version of Python")
+ # Prevent special LCG versions (like 2.7.9.p1) to confuse CMake
+ string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" Python_config_version "${Python_config_version}")
find_package(PythonInterp ${Python_config_version} QUIET)
find_package(PythonLibs ${Python_config_version} QUIET)
if(CMAKE_VERSION VERSION_GREATER 3.12)
@@ -363,10 +365,10 @@ macro(gaudi_project project version)
#-- Set up the boost_python_version variable for the project
find_package(PythonInterp)
find_package(Boost)
- if((Boost_VERSION GREATER 106700) OR (Boost_VERSION EQUAL 106700))
- set(boost_python_version "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
+ if((Boost_VERSION LESS 106700) OR (Boost_VERSION GREATER 1069000))
+ set(boost_python_version "")
else()
- set(boost_python_version "")
+ set(boost_python_version "${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
endif()
#--- Allow installation on failed builds
@@ -1607,9 +1609,25 @@ function(gaudi_resolve_link_libraries variable)
set(collected)
foreach(package ${ARGN})
# check if it is an actual library or a target first
+ if(NOT TARGET ${package})
+ if(package MATCHES "^Boost::(.*)$")
+ # special handling of Boost imported targets
+ find_package(Boost COMPONENTS ${CMAKE_MATCH_1} QUIET)
+ else()
+ # the target might be in a project namespace
+ foreach(_p IN LISTS used_gaudi_projects)
+ if(TARGET ${_p}::${package})
+ #message(STATUS "using ${_p}::${package} for ${package}")
+ set(package ${_p}::${package})
+ break()
+ endif()
+ endforeach()
+ endif()
+ endif()
+
if(TARGET ${package})
get_property(target_type TARGET ${package} PROPERTY TYPE)
- if(NOT target_type MATCHES "(SHARED|STATIC)_LIBRARY")
+ if(NOT target_type MATCHES "(SHARED|STATIC|UNKNOWN)_LIBRARY")
message(FATAL_ERROR "${package} is a ${target_type}: you cannot link against it")
endif()
#message(STATUS "${package} is a TARGET")
@@ -1657,6 +1675,19 @@ function(gaudi_resolve_link_libraries variable)
endforeach()
#message(STATUS "gaudi_resolve_link_libraries collected: ${collected}")
_gaudi_strip_build_type_libs(collected)
+ # resolve missing Boost::* targets, if needed
+ set(boost_components ${collected})
+ list(FILTER boost_components INCLUDE REGEX "^Boost::")
+ list(TRANSFORM boost_components REPLACE "^Boost::" "")
+ set(missing_components)
+ foreach(comp IN LISTS boost_components)
+ if(NOT TARGET Boost::${comp})
+ list(APPEND missing_components ${comp})
+ endif()
+ endforeach()
+ if(missing_components)
+ find_package(Boost COMPONENTS ${missing_components} QUIET)
+ endif()
#message(STATUS "gaudi_resolve_link_libraries output: ${collected}")
set(${variable} ${collected} PARENT_SCOPE)
endfunction()
@@ -3262,6 +3293,14 @@ macro(gaudi_external_project_environment)
list(FIND used_gaudi_projects ${pack} gaudi_project_idx)
if((NOT pack STREQUAL GaudiProject) AND (gaudi_project_idx EQUAL -1))
message(STATUS " ${pack}")
+ if(pack STREQUAL Boost)
+ if(NOT TARGET Boost::headers)
+ # this is needed to get the non-cache variables for the packages
+ # but we do not need to call it if we do not use FindBoost.cmake (Boost >= 1.70)
+ find_package(${pack} QUIET)
+ endif()
+ endif()
+
if(NOT pack MATCHES "^Python(Interp|Libs)?$")
# this is needed to get the non-cache variables for the packages
find_package(${pack} QUIET)
@@ -3310,6 +3349,17 @@ macro(gaudi_external_project_environment)
list(APPEND environment SET QT_XKB_CONFIG_ROOT "/usr/share/X11/xkb")
endif()
endif()
+ elseif(pack MATCHES "^boost_(.*)$")
+ # We are using BoostConfig.cmake (>=1.70) and not FindBoost.cmake
+ if(TARGET "Boost::${CMAKE_MATCH_1}")
+ set(tgt_name "Boost::${CMAKE_MATCH_1}")
+ get_property(target_type TARGET ${tgt_name} PROPERTY TYPE)
+ if(target_type MATCHES "(SHARED|UNKNOWN)_LIBRARY")
+ # FIXME: I'm not sure it's good to rely on the "_RELEASE" suffix
+ get_property(lib_path TARGET ${tgt_name} PROPERTY IMPORTED_LOCATION_RELEASE)
+ get_filename_component(${pack}_LIBRARY_DIR "${lib_path}" PATH)
+ endif()
+ endif()
endif()
list(APPEND binary_path ${${pack}_BINARY_PATH})

View File

@ -4,7 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
from spack.pkg.builtin.boost import Boost
class Gaudi(CMakePackage):
@ -57,11 +56,6 @@ class Gaudi(CMakePackage):
variant("vtune", default=False, description="Build with Intel VTune profiler support")
variant("xercesc", default=False, description="Build with Xerces-C XML support")
# only build subdirectory GaudiExamples when +examples
patch("build_testing.patch", when="@:34")
# fixes for the cmake config which could not find newer boost versions
patch("link_target_fixes.patch", when="@33.0:34")
patch("link_target_fixes32.patch", when="@:32.2")
patch("fmt_fix.patch", when="@36.6:36.12 ^fmt@10:")
# fix issues with catch2 3.1 and above
patch(
@ -78,18 +72,28 @@ class Gaudi(CMakePackage):
# These dependencies are needed for a minimal Gaudi build
depends_on("aida")
depends_on("boost@1.67.0: +python")
# The boost components that are required for Gaudi
boost_libs = "+".join(
[
"system",
"filesystem",
"regex",
"thread",
"python",
"test",
"program_options",
"log",
"graph",
]
)
depends_on(f"boost@1.70: +{boost_libs}", when="@35:")
depends_on(f"boost@1.70: +{boost_libs}+fiber", when="@39:")
# TODO: replace this with an explicit list of components of Boost,
# for instance depends_on('boost +filesystem')
# See https://github.com/spack/spack/pull/22303 for reference
depends_on(Boost.with_default_variants)
depends_on("clhep")
depends_on("cmake", type="build")
depends_on("cppgsl")
depends_on("fmt")
depends_on("fmt@:8", when="@:36.9")
depends_on("fmt@:10", when="@:39.0")
depends_on("fmt@:10")
depends_on("intel-tbb@:2020.3", when="@:37.0")
depends_on("tbb", when="@37.1:")
depends_on("uuid")