From e0527260ddc8c7c74fc5fda2c0208f41ab2a9e86 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sun, 12 Feb 2017 10:43:39 +0100 Subject: [PATCH] cmake: create relocatable dbus-1.pc file Relocatable pkgconfig files are required to use installed packages from a non standard location. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99721 --- cmake/CMakeLists.txt | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5eb9ed3..bddc822 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -84,6 +84,17 @@ set(SYSCONFDIR_FROM_PKGDATADIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}) set(DATADIR_FROM_PKGSYSCONFDIR ${CMAKE_INSTALL_FULL_DATADIR}) endif() +# For simplicity, we're not relocatable if CMAKE_INSTALL_LIBDIR +# is something more complicated (e.g. Debian multiarch); +# we don't want to have to compute how many ../ to add +if(CMAKE_INSTALL_LIBDIR STREQUAL "lib" OR CMAKE_INSTALL_LIBDIR STREQUAL "lib64") + # we know we can use ../ to get to the prefix + set(DBUS_RELOCATABLE_LIBDIR 1) +else() + # sorry, it's too hard to make this particular build relocatable + set(DBUS_RELOCATABLE_LIBDIR 0) +endif() + # used in the C code set(DBUS_LIBEXECDIR ${CMAKE_INSTALL_FULL_LIBEXECDIR}) set(DBUS_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}) @@ -638,13 +649,20 @@ if(UNIX) foreach(LIB ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS}) set(LIBDBUS_LIBS "${LIBDBUS_LIBS} -l${LIB}") endforeach() - set(bindir ${EXPANDED_BINDIR}) - set(libdir ${EXPANDED_LIBDIR}) - set(includedir ${EXPANDED_INCLUDEDIR}) - set(sysconfdir ${EXPANDED_SYSCONFDIR}) - set(datadir ${EXPANDED_DATADIR}) - set(datarootdir ${EXPANDED_DATADIR}) - set(dbus_daemondir ${DBUS_DAEMONDIR}) + if(DBUS_RELOCATABLE_LIBDIR) + set(prefix "\${pcfiledir}/../../") + else() + message("Unusual CMAKE_INSTALL_PREFIX: the generated package will not be relocatable.") + set(prefix "${CMAKE_INSTALL_PREFIX}") + endif() + set(exec_prefix "\${prefix}") + set(bindir "\${prefix}/${CMAKE_INSTALL_BINDIR}") + set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + set(sysconfdir "\${prefix}/${CMAKE_INSTALL_SYSCONFDIR}") + set(datadir "\${prefix}/${CMAKE_INSTALL_DATADIR}") + set(datarootdir "\${prefix}/${CMAKE_INSTALL_DATADIR}") + set(dbus_daemondir "\${prefix}/${CMAKE_INSTALL_BINDIR}") configure_file(../dbus-1.pc.in ${CMAKE_BINARY_DIR}/dbus-1.pc @ONLY) install(FILES ${CMAKE_BINARY_DIR}/dbus-1.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() -- 2.6.6