summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2020-03-13 22:08:19 +0100
committerPatrick Steinhardt <ps@pks.im>2020-03-14 11:18:20 +0100
commit87fc539f2ee733f86a83339a50aa3072d71890ef (patch)
treeba4223b8be14a786930fc22430cb54e85729036d /cmake
parente23b8b446522f17eb3329b62201aae7674f06e13 (diff)
downloadlibgit2-87fc539f2ee733f86a83339a50aa3072d71890ef.tar.gz
cmake: use install directories provided via GNUInstallDirs
We currently hand-code logic to configure where to install our artifacts via the `LIB_INSTALL_DIR`, `INCLUDE_INSTALL_DIR` and `BIN_INSTALL_DIR` variables. This is reinventing the wheel, as CMake already provide a way to do that via `CMAKE_INSTALL_<DIR>` paths, e.g. `CMAKE_INSTALL_LIB`. This requires users of libgit2 to know about the discrepancy and will require special hacks for any build systems that handle these variables in an automated way. One such example is Gentoo Linux, which sets up these paths in both the cmake and cmake-utils eclass. So let's stop doing that: the GNUInstallDirs module handles it in a better way for us, especially so as the actual values are dependent on CMAKE_INSTALL_PREFIX. This commit removes our own set of variables and instead refers users to use the standard ones. As a second benefit, this commit also fixes our pkgconfig generation to use the GNUInstallDirs module. We had a bug there where we ignored the CMAKE_INSTALL_PREFIX when configuring the libdir and includedir keys, so if libdir was set to "lib64", then libdir would be an invalid path. With GNUInstallDirs, we can now use `CMAKE_INSTALL_FULL_LIBDIR`, which handles the prefix for us.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/PkgBuildConfig.cmake8
1 files changed, 3 insertions, 5 deletions
diff --git a/cmake/Modules/PkgBuildConfig.cmake b/cmake/Modules/PkgBuildConfig.cmake
index e4c574431..54c5e294c 100644
--- a/cmake/Modules/PkgBuildConfig.cmake
+++ b/cmake/Modules/PkgBuildConfig.cmake
@@ -27,8 +27,8 @@ function(pkg_build_config)
# Write .pc "header"
file(WRITE "${PKGCONFIG_FILE}"
"prefix=\"${CMAKE_INSTALL_PREFIX}\"\n"
- "libdir=\"${LIB_INSTALL_DIR}\"\n"
- "includedir=\"${INCLUDE_INSTALL_DIR}\"\n"
+ "libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n"
+ "includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n"
"\n"
"Name: ${PKGCONFIG_NAME}\n"
"Description: ${PKGCONFIG_DESCRIPTION}\n"
@@ -73,7 +73,5 @@ function(pkg_build_config)
file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
# Install .pc file
- install(FILES "${PKGCONFIG_FILE}"
- DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
- )
+ install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endfunction()