mirror of
https://github.com/catchorg/Catch2.git
synced 2025-07-12 12:05:32 +02:00
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:
parent
39c32b9662
commit
3839e27f05
@ -1,10 +1,10 @@
|
|||||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
libdir=${prefix}/@lib_dir@
|
||||||
pkg_version=@Catch2_VERSION@
|
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)
|
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}
|
Version: ${pkg_version}
|
||||||
Requires: catch2 = ${pkg_version}
|
Requires: catch2 = ${pkg_version}
|
||||||
Cflags: -I${includedir}
|
Libs: -L${libdir} -l@lib_name@
|
||||||
Libs: -L${libdir} -lCatch2Main
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
exec_prefix=${prefix}
|
exec_prefix=${prefix}
|
||||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
includedir=${prefix}/@include_dir@
|
||||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
libdir=${prefix}/@lib_dir@
|
||||||
|
|
||||||
Name: Catch2
|
Name: Catch2
|
||||||
Description: A modern, C++-native, test framework for C++14 and above
|
Description: A modern, C++-native, test framework for C++14 and above
|
||||||
URL: https://github.com/catchorg/Catch2
|
URL: https://github.com/catchorg/Catch2
|
||||||
Version: @Catch2_VERSION@
|
Version: @Catch2_VERSION@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
Libs: -L${libdir} -lCatch2
|
Libs: -L${libdir} -l@lib_name@
|
||||||
|
@ -170,23 +170,41 @@ if(NOT_SUBPROJECT)
|
|||||||
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
||||||
CACHE PATH "Path where catch2.pc is installed"
|
CACHE PATH "Path where catch2.pc is installed"
|
||||||
)
|
)
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in
|
# Generate the pkg-config files
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/catch2.pc
|
# To understand the script below, you have to understand that it works in two steps.
|
||||||
@ONLY
|
# 1) A CMake script is generated at configuration time
|
||||||
)
|
# 2) It is executed at install time.
|
||||||
configure_file(
|
# And both of these have access to different parts of the information we need.
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2-with-main.pc.in
|
#
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/catch2-with-main.pc
|
# Further, the variables before "[[" are expanded at configuration time,
|
||||||
@ONLY
|
# while the ones inside the [[]] block are expanded at script execution (install) time.
|
||||||
)
|
string(
|
||||||
install(
|
JOIN "\n"
|
||||||
FILES
|
install_script
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/catch2.pc"
|
"set(install_pkgconfdir \"${PKGCONFIG_INSTALL_DIR}\")"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/catch2-with-main.pc"
|
"set(impl_pc_file \"${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in\")"
|
||||||
DESTINATION
|
"set(main_pc_file \"${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2-with-main.pc.in\")"
|
||||||
${PKGCONFIG_INSTALL_DIR}
|
"set(Catch2_VERSION ${Catch2_VERSION})"
|
||||||
|
"set(include_dir \"${CMAKE_INSTALL_INCLUDEDIR}\")"
|
||||||
|
"set(lib_dir \"${CMAKE_INSTALL_LIBDIR}\")"
|
||||||
|
[[
|
||||||
|
set(lib_name "$<TARGET_FILE_BASE_NAME:Catch2>")
|
||||||
|
configure_file(
|
||||||
|
"${impl_pc_file}"
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/${install_pkgconfdir}/catch2.pc"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
set(lib_name "$<TARGET_FILE_BASE_NAME:Catch2WithMain>")
|
||||||
|
configure_file(
|
||||||
|
"${main_pc_file}"
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/${install_pkgconfdir}/catch2-with-main.pc"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
]]
|
||||||
)
|
)
|
||||||
|
install(CODE "${install_script}")
|
||||||
|
|
||||||
set(CPACK_PACKAGE_CONTACT "https://github.com/catchorg/Catch2/")
|
set(CPACK_PACKAGE_CONTACT "https://github.com/catchorg/Catch2/")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user