Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-03-18 10:51:35 +0100
committerMartin Hořeňovský2020-03-18 10:51:35 +0100
commit121f04ffcf78e8bd2184b12e54b6388af0e537d9 (patch)
treebc80d398b876004a56a94c8b5ee12269abfe7538
parent0e7e6b210a51611a8d43a384f420cfca848fa205 (diff)
downloadcatch3-121f04ffcf78e8bd2184b12e54b6388af0e537d9.tar.gz
Update Catch2-provided pkg-config
Also fixes an installation issue, where some installation steps would not properly pick up `CMAKE_INSTALL_PREFIX` when set.
-rw-r--r--CMake/catch2-main.pc.in10
-rw-r--r--CMake/catch2.pc.in4
-rw-r--r--CMakeLists.txt14
3 files changed, 24 insertions, 4 deletions
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}
)