From 121f04ffcf78e8bd2184b12e54b6388af0e537d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 18 Mar 2020 10:51:35 +0100 Subject: [PATCH] Update Catch2-provided pkg-config Also fixes an installation issue, where some installation steps would not properly pick up `CMAKE_INSTALL_PREFIX` when set. --- CMake/catch2-main.pc.in | 10 ++++++++++ CMake/catch2.pc.in | 4 +++- CMakeLists.txt | 14 +++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 CMake/catch2-main.pc.in diff --git a/CMake/catch2-main.pc.in b/CMake/catch2-main.pc.in new file mode 100644 index 00000000..4189cc77 --- /dev/null +++ b/CMake/catch2-main.pc.in @@ -0,0 +1,10 @@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +pkg_version=@Catch2_VERSION@ + +Name: Catch2-Main +Description: Links in the default main function for Catch2 +Version: ${pkg_version} +Requires: catch2 = ${pkg_version} +Cflags: -I${includedir} +Libs: -L${libdir} -lCatch2Main diff --git a/CMake/catch2.pc.in b/CMake/catch2.pc.in index 3ac9fbd1..183114b6 100644 --- a/CMake/catch2.pc.in +++ b/CMake/catch2.pc.in @@ -1,7 +1,9 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ Name: Catch2 -Description: A modern, C++-native, header-only, test framework for C++11 +Description: A modern, C++-native, header-only, test framework for C++14 and above URL: https://github.com/catchorg/Catch2 Version: @Catch2_VERSION@ Cflags: -I${includedir} +Libs: -L${libdir} -lCatch2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 37a930ce..b27bcd7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,6 @@ cmake_dependent_option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF "CATCH_DE cmake_dependent_option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF "CATCH_DEVELOPMENT_BUILD" OFF) cmake_dependent_option(CATCH_ENABLE_WERROR "Enables Werror during build" ON "CATCH_DEVELOPMENT_BUILD" OFF) -set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2") - # Catch2's build breaks if done in-tree. You probably should not build # things in tree anyway, but we can allow projects that include Catch2 # as a subproject to build in-tree as long as it is not in our tree. @@ -35,6 +33,11 @@ include(GNUInstallDirs) include(CMakePackageConfigHelpers) include(CTest) +# This variable is used in some subdirectories, so we need it here, rather +# than later in the install block +set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2") + + # Basic paths set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(SOURCES_DIR ${CATCH_DIR}/src/catch2) @@ -84,7 +87,6 @@ endif() # a subproject via `add_subdirectory`, or the destinations will break, # see https://github.com/catchorg/Catch2/issues/1373 if (NOT_SUBPROJECT) - configure_package_config_file( ${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake @@ -163,9 +165,15 @@ if (NOT_SUBPROJECT) ${CMAKE_CURRENT_BINARY_DIR}/catch2.pc @ONLY ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2-main.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/catch2-main.pc + @ONLY + ) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/catch2.pc" + "${CMAKE_CURRENT_BINARY_DIR}/catch2-main.pc" DESTINATION ${PKGCONFIG_INSTALL_DIR} )