blob: 615c90aaac564b029d4ce16bb0d46db63c8bb1a9 (
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
|
--- cmake/Modules/G4OptionalComponents.cmake.orig 2023-12-10 17:01:37 UTC
+++ cmake/Modules/G4OptionalComponents.cmake
@@ -38,8 +38,31 @@ endif()
option(GEANT4_USE_SYSTEM_CLHEP "Use system CLHEP library" ${_default_use_system_clhep})
+#[[CLHEP installs CMake Config files not, e.g., to '<prefix>/libdata/CLHEP/' (where CMake
+ would have no trouble finding the files), but to '<prefix>/libdata/CLHEP-<VERSION>/'.
+ There is no straight-forward way to communicate this to CMake's `find_package`, but
+ we can provide a list of additional PATHS for CMake to try as *prefixes*.
+ We find all absolute paths from the system's pre-defined prefixes to directories
+ containing a file "CLHEPConfig.cmake" and provide these paths as prefixes, slightly
+ abusing the fact that one of CMake's search paths is just '<prefix>/'.
+ See https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure.]]
+unset(_paths)
+foreach(_prefix ${CMAKE_SYSTEM_PREFIX_PATH})
+ file(GLOB _find_results ${_prefix}/*/CLHEP*)
+ list(APPEND _paths ${_find_results})
+endforeach()
+list(REMOVE_DUPLICATES _paths)
+foreach(_path ${_paths})
+ file(GLOB _find_results ${_path}/CLHEPConfig.cmake)
+ if("${_find_results}" STREQUAL "")
+ list(REMOVE_ITEM _paths ${_path})
+ endif()
+endforeach()
+unset(_find_results)
if(GEANT4_USE_SYSTEM_CLHEP)
- find_package(CLHEP 2.4.6.0 REQUIRED CONFIG)
+ find_package(CLHEP 2.4.6.0 REQUIRED CONFIG
+ PATHS ${_paths}) # PATHS added by port maintainer
+ unset(_paths)
geant4_save_package_variables(CLHEP CLHEP_DIR)
else()
set(CLHEP_FOUND TRUE)
|