From 89429885a0160156360b54001f707cb143d39d67 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 9 Oct 2023 10:00:58 +0200 Subject: [PATCH] [cmake] make generated pkg-config files relocatable * new CMake option PKG_CONFIG_RELOCATABLE (default ON) allows generating traditional or relocatable pc files --- client/CMakeLists.txt | 1 + client/freerdp-client.pc.in | 2 +- cmake/pkg-config-install-prefix.cmake | 6 ++++++ libfreerdp/CMakeLists.txt | 1 + libfreerdp/freerdp.pc.in | 2 +- rdtk/templates/CMakeLists.txt | 2 ++ rdtk/templates/rdtk.pc.in | 2 +- server/CMakeLists.txt | 1 + server/freerdp-server.pc.in | 2 +- server/proxy/CMakeLists.txt | 1 + server/proxy/freerdp-proxy.pc.in | 2 +- server/shadow/CMakeLists.txt | 1 + server/shadow/freerdp-shadow.pc.in | 2 +- uwac/templates/CMakeLists.txt | 1 + uwac/templates/uwac.pc.in | 2 +- winpr/CMakeLists.txt | 1 + winpr/tools/CMakeLists.txt | 1 + winpr/tools/winpr-tools.pc.in | 2 +- winpr/winpr.pc.in | 2 +- 19 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 cmake/pkg-config-install-prefix.cmake diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 65dd4b8b7..96b01d3b2 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -92,6 +92,7 @@ if(WITH_CLIENT) endforeach() 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) diff --git a/client/freerdp-client.pc.in b/client/freerdp-client.pc.in index 124c56f4c..eca4ab897 100644 --- a/client/freerdp-client.pc.in +++ b/client/freerdp-client.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@FREERDP_INCLUDE_DIR@ diff --git a/cmake/pkg-config-install-prefix.cmake b/cmake/pkg-config-install-prefix.cmake new file mode 100644 index 000000000..f3bd2ed38 --- /dev/null +++ b/cmake/pkg-config-install-prefix.cmake @@ -0,0 +1,6 @@ +option(PKG_CONFIG_RELOCATABLE "Generate relocatable pkg-config files" ON) +if (PKG_CONFIG_RELOCATABLE) + set(PKG_CONFIG_INSTALL_PREFIX "\${pcfiledir}/../..") +else() + set(PKG_CONFIG_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +endif() diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index defcecb5d..fcadbedf3 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -436,6 +436,7 @@ endif() 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) diff --git a/libfreerdp/freerdp.pc.in b/libfreerdp/freerdp.pc.in index 1429eb043..755595789 100644 --- a/libfreerdp/freerdp.pc.in +++ b/libfreerdp/freerdp.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@FREERDP_INCLUDE_DIR@ diff --git a/rdtk/templates/CMakeLists.txt b/rdtk/templates/CMakeLists.txt index 7439758ff..41e100126 100644 --- a/rdtk/templates/CMakeLists.txt +++ b/rdtk/templates/CMakeLists.txt @@ -23,6 +23,8 @@ FOREACH(var ${res}) ENDIF() ENDFOREACH() +include(pkg-config-install-prefix) + string(REPLACE ";" " " RDTK_BUILD_CONFIG "${RDTK_BUILD_CONFIG_LIST}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/version.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/buildflags.h) diff --git a/rdtk/templates/rdtk.pc.in b/rdtk/templates/rdtk.pc.in index 39c57fd03..aed9f3b1b 100644 --- a/rdtk/templates/rdtk.pc.in +++ b/rdtk/templates/rdtk.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@RDTK_INCLUDE_DIR@ diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 88e8fd6a0..538db3f4e 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -72,6 +72,7 @@ foreach(FREERDP_SERVER ${FREERDP_EXTRA_SERVERS}) add_subdirectory(${FREERDP_SERVER}) 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) diff --git a/server/freerdp-server.pc.in b/server/freerdp-server.pc.in index 1c0a6d816..d7d662966 100644 --- a/server/freerdp-server.pc.in +++ b/server/freerdp-server.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@FREERDP_INCLUDE_DIR@ diff --git a/server/proxy/CMakeLists.txt b/server/proxy/CMakeLists.txt index 93beb07b4..c17ad7adf 100644 --- a/server/proxy/CMakeLists.txt +++ b/server/proxy/CMakeLists.txt @@ -88,6 +88,7 @@ if (WITH_DEBUG_SYMBOLS AND MSVC) install(FILES ${CMAKE_PDB_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) endif() # 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) diff --git a/server/proxy/freerdp-proxy.pc.in b/server/proxy/freerdp-proxy.pc.in index 53bc83aed..465507523 100644 --- a/server/proxy/freerdp-proxy.pc.in +++ b/server/proxy/freerdp-proxy.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@FREERDP_INCLUDE_DIR@ diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index c08f7217a..52a49b5b8 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -214,6 +214,7 @@ endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/shadow") +include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-shadow.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc @ONLY) configure_file(freerdp-shadow-cli.1.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow-cli.1) install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow-cli.1 1) diff --git a/server/shadow/freerdp-shadow.pc.in b/server/shadow/freerdp-shadow.pc.in index fc5a24a84..805e2af41 100644 --- a/server/shadow/freerdp-shadow.pc.in +++ b/server/shadow/freerdp-shadow.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@FREERDP_INCLUDE_DIR@ diff --git a/uwac/templates/CMakeLists.txt b/uwac/templates/CMakeLists.txt index 8499c3a2f..afb8a39b6 100644 --- a/uwac/templates/CMakeLists.txt +++ b/uwac/templates/CMakeLists.txt @@ -35,6 +35,7 @@ configure_file(buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/build configure_file(build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/build-config.h) configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/config.h) +include(pkg-config-install-prefix) configure_file(uwac.pc.in ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc @ONLY) set(UWAC_INSTALL_INCLUDE_DIR ${UWAC_INCLUDE_DIR}/uwac) diff --git a/uwac/templates/uwac.pc.in b/uwac/templates/uwac.pc.in index aecf14285..c0abdee19 100644 --- a/uwac/templates/uwac.pc.in +++ b/uwac/templates/uwac.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@UWAC_INCLUDE_DIR@ diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 2c90dd1a1..4195e43d3 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -343,6 +343,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfig.cmake ${CMAKE_CURRENT_BINA 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) diff --git a/winpr/tools/CMakeLists.txt b/winpr/tools/CMakeLists.txt index 1325514fb..e995172fc 100644 --- a/winpr/tools/CMakeLists.txt +++ b/winpr/tools/CMakeLists.txt @@ -128,6 +128,7 @@ set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools") add_subdirectory(makecert-cli) 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) diff --git a/winpr/tools/winpr-tools.pc.in b/winpr/tools/winpr-tools.pc.in index b9d3a0a3c..689825388 100644 --- a/winpr/tools/winpr-tools.pc.in +++ b/winpr/tools/winpr-tools.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@WINPR_INCLUDE_DIR@ diff --git a/winpr/winpr.pc.in b/winpr/winpr.pc.in index 9dc570895..d4f9c0852 100644 --- a/winpr/winpr.pc.in +++ b/winpr/winpr.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@WINPR_INCLUDE_DIR@