From 852319186a2519f7e1600d3c1b4ff9812b7ecba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 3 Sep 2019 08:41:01 +0200 Subject: [PATCH 1/2] pkgconfig: Fix support for absolute lib and include dirs Using GNUInstallDirs to always have an absolute path regardless of the user input: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2bd5092a..94edb6dc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,22 +273,22 @@ endif() # .so version set_property(TARGET lcf PROPERTY SOVERSION 0) +# installation +include(GNUInstallDirs) + # pkg-config file generation set(PACKAGE_TARNAME ${PROJECT_NAME}) set(PACKAGE_VERSION ${PROJECT_VERSION}) set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\${prefix}") -set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") -set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") +set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") string(REPLACE ";" " " AX_PACKAGE_REQUIRES_PRIVATE "${LIBLCF_DEPS}") configure_file(builds/${PROJECT_NAME}.pc.in builds/${PROJECT_NAME}.pc @ONLY) # Cmake-config file generation configure_file(builds/${PROJECT_NAME}-config.cmake.in builds/${PROJECT_NAME}-config.cmake @ONLY) -# installation -include(GNUInstallDirs) - install( TARGETS lcf ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} From a1472c67aa4ac26f03e2fb6ebefadae501cb1cc8 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Sun, 26 Apr 2020 21:44:24 +0200 Subject: [PATCH 2/2] CMake: pkgconfig: Preserve execprefix and support absolute lib/include dirs --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94edb6dc6..54dbaaafe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,12 +277,21 @@ set_property(TARGET lcf PROPERTY SOVERSION 0) include(GNUInstallDirs) # pkg-config file generation +set(LCF_LIBDIR ${CMAKE_INSTALL_LIBDIR}) +if(IS_ABSOLUTE ${LCF_LIBDIR}) + file(RELATIVE_PATH LCF_LIBDIR ${CMAKE_INSTALL_PREFIX} ${LCF_LIBDIR}) +endif() +set(LCF_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) +if(IS_ABSOLUTE ${LCF_INCLUDEDIR}) + file(RELATIVE_PATH LCF_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${LCF_INCLUDEDIR}) +endif() + set(PACKAGE_TARNAME ${PROJECT_NAME}) set(PACKAGE_VERSION ${PROJECT_VERSION}) set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\${prefix}") -set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") -set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") +set(libdir "\${exec_prefix}/${LCF_LIBDIR}") +set(includedir "\${prefix}/${LCF_INCLUDEDIR}") string(REPLACE ";" " " AX_PACKAGE_REQUIRES_PRIVATE "${LIBLCF_DEPS}") configure_file(builds/${PROJECT_NAME}.pc.in builds/${PROJECT_NAME}.pc @ONLY)