File: 0001-Install-cmake-package-configuration-to-correct-locat.patch

package info (click to toggle)
opm-common 2025.10%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 96,912 kB
  • sloc: cpp: 291,772; python: 3,609; sh: 198; xml: 174; pascal: 136; makefile: 12
file content (64 lines) | stat: -rw-r--r-- 2,857 bytes parent folder | download | duplicates (4)
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
From: Markus Blatt <markus@dr-blatt.de>
Date: Wed, 31 Mar 2021 23:18:32 +0200
Subject: Install cmake package configuration to correct location with lib.

If we ship a library than we are architecture dependent and should
allow for installations for multiple architectures. For this to work
the package configuration files need to be installed in an
architecture aware location (e.g. lib/arch/cmake/module_name on
Debian). Just like the pkg-config files. This is done with this patch.
---
 cmake/Modules/OpmInstall.cmake |  2 +-
 cmake/Modules/OpmProject.cmake | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/cmake/Modules/OpmInstall.cmake b/cmake/Modules/OpmInstall.cmake
index eedfc54..28ba99f 100644
--- a/cmake/Modules/OpmInstall.cmake
+++ b/cmake/Modules/OpmInstall.cmake
@@ -28,7 +28,7 @@ macro (opm_install opm)
   if(NOT "${${opm}_TARGET}" STREQUAL "")
     export(TARGETS ${${opm}_TARGET} ${${opm}_EXTRA_TARGETS}
             FILE ${opm}-targets.cmake)
-    install(EXPORT ${opm}-targets DESTINATION "share/cmake/${opm}")
+    install(EXPORT ${opm}-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${opm})
   endif()
   # only /usr/lib/debug seems to be searched for debug info; if we have
   # write access to that directory (package installation), then default
diff --git a/cmake/Modules/OpmProject.cmake b/cmake/Modules/OpmProject.cmake
index db473fe..41d4c16 100644
--- a/cmake/Modules/OpmProject.cmake
+++ b/cmake/Modules/OpmProject.cmake
@@ -100,15 +100,30 @@ function (opm_cmake_config name)
 	FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake"
 	APPEND "${${name}_CONFIG_VARS}"
 	)
+
+  # put this in the right system location; if we have binaries then it
+  # should go in the arch-specific lib/ directory, otherwise use the
+  # common/noarch lib/ directory (these targets come from UseMultiArch)
+  if (${name}_TARGET)
+    set (_pkg_dir ${CMAKE_INSTALL_LIBDIR})
+  else ()
+    set (_pkg_dir lib)
+  endif ()
+
+  # If there is a library then the cmake package configuration file is architecture
+  # dependent and should move to the corresponding multiarch libdir.
+  # Really no idea what ${name}_VER_DIR is and when it is needed.
+  set (_cmake_config_dir ${CMAKE_INSTALL_PREFIX}/${_pkg_dir}/cmake${${name}_VER_DIR}/${${name}_NAME})
+
   # this file gets copied to the final installation directory
   install (
 	FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake
-	DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
+	DESTINATION ${_cmake_config_dir}
 	RENAME ${${name}_NAME}-config.cmake
 	)
   # assume that there exists a version file already
   install (
 	FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
-	DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
+	DESTINATION ${_cmake_config_dir}
 	)
 endfunction (opm_cmake_config name)