summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/gaudi/link_target_fixes.patch
blob: 468c117b517379fddb194f69107aa306279468dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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})