mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-08 09:08:15 +02:00
cmake: Optionally create relocatable dbus-1.pc file
Relocatable pkgconfig files are necessary when using packages installed to
a location that does not match the location for which they were compiled.
However, using ${pcfiledir} is problematic for system installations
in standard locations, because it interferes with pkg-config's
ability to filter out -I, -L options that are redundant with compiler
defaults (which is important if you are trying to use a newer version
of a library than the system copy).
In practice operating system vendors installing dbus to standard
locations use Autotools, so we enable relocatable builds by default
when building with CMake.
For simplicity, we're also not relocatable if the library directory
is something more complicated than lib or lib64 (e.g. under Debian
multiarch); we don't want to have to compute how many ../ to add.
This is non-trivial to determine in an Autotools build, so for now
there is no support for relocation when built with Autotools,
even as an opt-in feature.
Going via the ${original_prefix} variable is because under Autotools,
both ${prefix} and ${exec_prefix} technically default to NONE, with
NONE replaced with their real defaults of /usr/local and '${prefix}'
(respectively) later on. If we tried to expand ${prefix} at the time
that we choose the value of ${pkgconfig_prefix}, that would cause
a broken value "prefix=NONE" to be hard-coded.
[smcv: no relocation on Autotools, make it optional in CMake,
expand commit message]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99721
Reviewed-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
71959d5bca
commit
216627825d
3 changed files with 32 additions and 8 deletions
|
|
@ -84,6 +84,19 @@ set(SYSCONFDIR_FROM_PKGDATADIR ${CMAKE_INSTALL_FULL_SYSCONFDIR})
|
|||
set(DATADIR_FROM_PKGSYSCONFDIR ${CMAKE_INSTALL_FULL_DATADIR})
|
||||
endif()
|
||||
|
||||
option (DBUS_RELOCATABLE "Attempt to make metadata relocatable" ON)
|
||||
|
||||
# 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. Do nothing.
|
||||
elseif(DBUS_RELOCATABLE)
|
||||
# Sorry, it's too hard to make this particular build relocatable
|
||||
message("Unusual CMAKE_INSTALL_LIBDIR: the generated package will not be relocatable.")
|
||||
set(DBUS_RELOCATABLE OFF)
|
||||
endif()
|
||||
|
||||
# used in the C code
|
||||
set(DBUS_LIBEXECDIR ${CMAKE_INSTALL_FULL_LIBEXECDIR})
|
||||
set(DBUS_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
|
||||
|
|
@ -638,13 +651,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})
|
||||
set(original_prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
if(DBUS_RELOCATABLE)
|
||||
set(pkgconfig_prefix "\${pcfiledir}/../../")
|
||||
else()
|
||||
set(pkgconfig_prefix "\${original_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()
|
||||
|
|
|
|||
|
|
@ -1530,6 +1530,9 @@ AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir")
|
|||
AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir")
|
||||
AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir")
|
||||
|
||||
# For the moment we don't support relocation when building with Autotools
|
||||
AC_SUBST([pkgconfig_prefix], ['${original_prefix}'])
|
||||
|
||||
#### Check our operating system
|
||||
operating_system=unknown
|
||||
if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
prefix=@prefix@
|
||||
original_prefix=@prefix@
|
||||
prefix=@pkgconfig_prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue