Generate pkg-config files at install time

This enables us to generate pkg-config with proper paths if the
installation prefix is decided at install time, e.g. with
```
cmake --install build-dir --prefix /path/to/somewhere
```

It also means that we can use CMake's generator expression to get
the _real_ final name of the libraries, e.g. including debug postfix.

Closes #2979
This commit is contained in:
Martin Hořeňovský
2025-07-10 16:39:42 +02:00
parent 39c32b9662
commit 3839e27f05
3 changed files with 42 additions and 24 deletions

View File

@@ -1,10 +1,10 @@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/@lib_dir@
pkg_version=@Catch2_VERSION@
Name: Catch2-With-Main
Name: Catch2 with main function
Description: A modern, C++-native test framework for C++14 and above (links in default main)
URL: https://github.com/catchorg/Catch2
Version: ${pkg_version}
Requires: catch2 = ${pkg_version}
Cflags: -I${includedir}
Libs: -L${libdir} -lCatch2Main
Libs: -L${libdir} -l@lib_name@

View File

@@ -1,11 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=${prefix}/@include_dir@
libdir=${prefix}/@lib_dir@
Name: Catch2
Description: A modern, C++-native, test framework for C++14 and above
URL: https://github.com/catchorg/Catch2
Version: @Catch2_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lCatch2
Libs: -L${libdir} -l@lib_name@