cmake: make the .pc file relocatable

Instead of writing absolute file paths for exec_prefix, libdir and
includedir make them all relative to prefix. This makes the .pc
file match the autotools generated one and allows changing all paths
via prefix.

Before:

prefix=C:/test
exec_prefix=C:/test
libdir=C:/test/lib
includedir=C:/test/include

After:

prefix=C:/test
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
This commit is contained in:
Christoph Reiter 2022-10-31 19:20:00 +01:00
parent cb11cfcd2c
commit 9128054a12
1 changed files with 3 additions and 3 deletions

View File

@ -457,9 +457,9 @@ set(abs_top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
set(abs_top_builddir "${CMAKE_CURRENT_BINARY_DIR}") set(abs_top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
# libnghttp2.pc (pkg-config file) # libnghttp2.pc (pkg-config file)
set(prefix "${CMAKE_INSTALL_PREFIX}") set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\${prefix}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(VERSION "${PACKAGE_VERSION}") set(VERSION "${PACKAGE_VERSION}")
# For init scripts and systemd service file (in contrib/) # For init scripts and systemd service file (in contrib/)
set(bindir "${CMAKE_INSTALL_FULL_BINDIR}") set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")