summaryrefslogtreecommitdiff
blob: b867e7ca9680530b7b72c212337935bca5b10cc9 (plain)
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
From 02c781a35a844f0ef4434268fb0d7f9ea2d3f130 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Thu, 26 Mar 2020 13:07:37 +0100
Subject: [PATCH] Use GNUInstallDirs

Fix cmake module install path while at it.
Fix pkgconfig libdir path while at it.
---
 CMakeLists.txt          | 15 +++++++--------
 RinutilsConfig.cmake.in |  2 +-
 librinutils.pc.in       |  4 ++--
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9829c49..753a138 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ option (WITH_TEST_SUITE "Also build and run the test suite." ON)
 option (DISABLE_APPLYING_RPATH "Disable applying rpath")
 
 INCLUDE(FindPkgConfig)
+INCLUDE(GNUInstallDirs)
 
 # Introduces VERSION , CPACK_PACKAGE_VERSION_MAJOR,
 # CPACK_PACKAGE_VERSION_MAJOR, and CPACK_PACKAGE_VERSION_PATCH
@@ -54,7 +55,7 @@ IF (NOT DISABLE_APPLYING_RPATH)
     SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
     # the RPATH to be used when installing
-    SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
+    SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
 
     # add the automatically determined parts of the RPATH
     # which point to directories outside the build tree to the install RPATH
@@ -99,14 +100,14 @@ INSTALL(
         "rinutils/include/rinutils/typeof_wrap.h"
         "rinutils/include/rinutils/unused.h"
     DESTINATION
-        "include/rinutils"
+        "${CMAKE_INSTALL_INCLUDEDIR}/rinutils"
 )
 
 INSTALL(
     FILES
         "${CMAKE_CURRENT_BINARY_DIR}/lib${CPACK_PACKAGE_NAME}.pc"
     DESTINATION
-        "lib${LIB_SUFFIX}/pkgconfig"
+        "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
 )
 
 CONFIGURE_FILE(
@@ -128,20 +129,18 @@ ADD_CUSTOM_COMMAND(
     ARGS "config.h.in"
 )
 
-set(INCLUDE_INSTALL_DIR include)
-set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
 include(CMakePackageConfigHelpers)
 configure_package_config_file(RinutilsConfig.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/RinutilsConfig.cmake
-  INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Rinutils/cmake
-  PATH_VARS INCLUDE_INSTALL_DIR)
+  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Rinutils
+  PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
 write_basic_package_version_file(
   ${CMAKE_CURRENT_BINARY_DIR}/RinutilsConfigVersion.cmake
   VERSION 1.2.3
   COMPATIBILITY SameMajorVersion )
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/RinutilsConfig.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/RinutilsConfigVersion.cmake
-        DESTINATION ${LIB_INSTALL_DIR}/Rinutils/cmake )
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Rinutils )
 
 IF (WITH_TEST_SUITE)
 
diff --git a/RinutilsConfig.cmake.in b/RinutilsConfig.cmake.in
index 480fda0..f81f685 100644
--- a/RinutilsConfig.cmake.in
+++ b/RinutilsConfig.cmake.in
@@ -2,6 +2,6 @@ set(RINUTILS_VERSION x.y.z)
 
 @PACKAGE_INIT@
 
-set_and_check(RINUTILS_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
+set_and_check(RINUTILS_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
 
 check_required_components(Rinutils)
diff --git a/librinutils.pc.in b/librinutils.pc.in
index 6cdb514..1af6238 100644
--- a/librinutils.pc.in
+++ b/librinutils.pc.in
@@ -1,7 +1,7 @@
 prefix="@CMAKE_INSTALL_PREFIX@"
 exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
 
 Name:  rinutils
 Description: Ad hoc headers library for C
-- 
2.26.0