From f6a208f75e61ab55c79408093f6677caf3d63fb7 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 2 Jan 2024 19:51:33 +0100 Subject: [PATCH] [cmake] generate relative pkgconfig path generate the relative pkgconfig path from the actual install locations. fixes #9718 --- client/CMakeLists.txt | 2 +- cmake/pkg-config-install-prefix.cmake | 9 ++++++++- libfreerdp/CMakeLists.txt | 2 +- rdtk/templates/CMakeLists.txt | 2 +- server/CMakeLists.txt | 2 +- server/proxy/CMakeLists.txt | 2 +- server/shadow/CMakeLists.txt | 2 +- uwac/templates/CMakeLists.txt | 2 +- winpr/CMakeLists.txt | 2 +- winpr/tools/CMakeLists.txt | 2 +- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 96b01d3b2..fcb0d403c 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -94,7 +94,7 @@ endif() include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-client.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) export(PACKAGE freerdp-client) diff --git a/cmake/pkg-config-install-prefix.cmake b/cmake/pkg-config-install-prefix.cmake index f3bd2ed38..600b2f7bd 100644 --- a/cmake/pkg-config-install-prefix.cmake +++ b/cmake/pkg-config-install-prefix.cmake @@ -1,6 +1,13 @@ option(PKG_CONFIG_RELOCATABLE "Generate relocatable pkg-config files" ON) if (PKG_CONFIG_RELOCATABLE) - set(PKG_CONFIG_INSTALL_PREFIX "\${pcfiledir}/../..") + file(RELATIVE_PATH PKG_CONFIG_INSTALL_REL ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig ${CMAKE_INSTALL_PREFIX}) + if (PKG_CONFIG_INSTALL_REL MATCHES "/$") + string(LENGTH ${PKG_CONFIG_INSTALL_REL} PKG_CONFIG_INSTALL_REL_LEN) + math(EXPR PKG_CONFIG_INSTALL_REL_LEN "${PKG_CONFIG_INSTALL_REL_LEN} - 1") + string(SUBSTRING ${PKG_CONFIG_INSTALL_REL} 0 ${PKG_CONFIG_INSTALL_REL_LEN} PKG_CONFIG_INSTALL_REL) + endif() + set(PKG_CONFIG_INSTALL_PREFIX "\${pcfiledir}/${PKG_CONFIG_INSTALL_REL}") else() set(PKG_CONFIG_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) endif() +set(PKG_CONFIG_PC_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index 260373d7f..8086e6235 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -474,7 +474,7 @@ set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) ## cmake project export(PACKAGE freerdp) diff --git a/rdtk/templates/CMakeLists.txt b/rdtk/templates/CMakeLists.txt index 6efabc578..fd00820fd 100644 --- a/rdtk/templates/CMakeLists.txt +++ b/rdtk/templates/CMakeLists.txt @@ -39,7 +39,7 @@ if (NOT RDTK_FORCE_STATIC_BUILD) set(RDTK_INSTALL_INCLUDE_DIR ${RDTK_INCLUDE_DIR}/rdtk) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rdtkConfig.cmake diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 538db3f4e..895b7a445 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -74,7 +74,7 @@ endforeach() include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-server${FREERDP_VERSION_MAJOR}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-server${FREERDP_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-server${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) export(PACKAGE freerdp-server) diff --git a/server/proxy/CMakeLists.txt b/server/proxy/CMakeLists.txt index 758b3938b..4693b1722 100644 --- a/server/proxy/CMakeLists.txt +++ b/server/proxy/CMakeLists.txt @@ -99,7 +99,7 @@ set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Proxy") # pkg-config include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-proxy.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) export(PACKAGE freerdp-proxy) diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index 7ca4e7d7c..72adcca76 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -225,7 +225,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-shadow.pc.in ${CMAKE_CURRENT_ configure_file(freerdp-shadow-cli.1.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1) install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1 1) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) export(PACKAGE freerdp-shadow) diff --git a/uwac/templates/CMakeLists.txt b/uwac/templates/CMakeLists.txt index a8dac7b83..14dfc684a 100644 --- a/uwac/templates/CMakeLists.txt +++ b/uwac/templates/CMakeLists.txt @@ -43,5 +43,5 @@ if (NOT UWAC_FORCE_STATIC_BUILD) configure_file(uwac.pc.in ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc @ONLY) set(UWAC_INSTALL_INCLUDE_DIR ${UWAC_INCLUDE_DIR}/uwac) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) endif() diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 98b01ce44..66643cd6b 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -366,4 +366,4 @@ install(EXPORT WinPRTargets DESTINATION ${WINPR_CMAKE_INSTALL_DIR}) include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) diff --git a/winpr/tools/CMakeLists.txt b/winpr/tools/CMakeLists.txt index e995172fc..ed7734d00 100644 --- a/winpr/tools/CMakeLists.txt +++ b/winpr/tools/CMakeLists.txt @@ -130,7 +130,7 @@ add_subdirectory(hash-cli) include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr-tools.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr-tools${WINPR_TOOLS_VERSION_MAJOR}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr-tools${WINPR_TOOLS_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr-tools${WINPR_TOOLS_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) export(PACKAGE ${MODULE_NAME})