CMakeLists: make daedalus-fourier.pc relocatable via ${pcfiledir} #5
+25
-1
@@ -419,9 +419,33 @@ endif()
|
|||||||
# pkg-config file. Vulkan goes in Requires.private (consumer's
|
# pkg-config file. Vulkan goes in Requires.private (consumer's
|
||||||
# pkg-config call gets it via --static). pthread + dl are needed
|
# pkg-config call gets it via --static). pthread + dl are needed
|
||||||
# by the static archive's runtime helpers.
|
# by the static archive's runtime helpers.
|
||||||
|
#
|
||||||
|
# `prefix` is derived from ${pcfiledir} so the .pc is relocatable:
|
||||||
|
# pkg-config substitutes ${pcfiledir} with the directory holding the
|
||||||
|
# .pc at lookup time, and the relative path from
|
||||||
|
# <prefix>/<libdir>/pkgconfig back to <prefix> tells pkg-config the
|
||||||
|
# install prefix without baking it in. This is why
|
||||||
|
# `cmake --install build --prefix /foo` produces a .pc that correctly
|
||||||
|
# resolves `prefix=/foo` instead of baking whatever CMAKE_INSTALL_PREFIX
|
||||||
|
# was at *configure* time (default /usr/local). DESTDIR-staged
|
||||||
|
# installs work too: at runtime pkg-config sees the .pc at its real
|
||||||
|
# install path and computes the right prefix.
|
||||||
|
#
|
||||||
|
# Relative-path depth is computed from CMAKE_INSTALL_LIBDIR (and
|
||||||
|
# whatever multiarch tuple GNUInstallDirs adds) so Debian-style
|
||||||
|
# `lib/aarch64-linux-gnu/pkgconfig/...` resolves with the right number
|
||||||
|
# of `..` components. Layouts where libdir is *not* under prefix are
|
||||||
|
# not supported by this scheme; if a packager overrides libdir to an
|
||||||
|
# absolute path the relative-path machinery falls back to the absolute
|
||||||
|
# value (CMake's file(RELATIVE_PATH) prepends `..` until they meet),
|
||||||
|
# which is also relocatable but no longer prefix-agnostic.
|
||||||
|
file(RELATIVE_PATH PKGCONFIG_PCDIR_TO_PREFIX
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||||
|
"${CMAKE_INSTALL_PREFIX}")
|
||||||
|
|
||||||
set(PKGCONFIG_OUT ${CMAKE_CURRENT_BINARY_DIR}/daedalus-fourier.pc)
|
set(PKGCONFIG_OUT ${CMAKE_CURRENT_BINARY_DIR}/daedalus-fourier.pc)
|
||||||
file(WRITE ${PKGCONFIG_OUT}
|
file(WRITE ${PKGCONFIG_OUT}
|
||||||
"prefix=${CMAKE_INSTALL_PREFIX}
|
"prefix=\${pcfiledir}/${PKGCONFIG_PCDIR_TO_PREFIX}
|
||||||
exec_prefix=\${prefix}
|
exec_prefix=\${prefix}
|
||||||
libdir=\${prefix}/${CMAKE_INSTALL_LIBDIR}
|
libdir=\${prefix}/${CMAKE_INSTALL_LIBDIR}
|
||||||
includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}
|
includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
|||||||
Reference in New Issue
Block a user