Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Separate Catch2Config from targets

This lets us add the installed helper scripts to the cmake module
path, letting CMake users just include them after requiring Catch2
package.
Commit
1af60ef5ab661e2e456ad52cf749d8e1e4f6403e
Author
Martin Hořeňovský ·
Parents
3743295ca89d

Files · Download .tar.gz

Changes

 CMake/Catch2Config.cmake.in | 10 ++++++++++
 CMakeLists.txt              | 18 +++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/CMake/Catch2Config.cmake.in b/CMake/Catch2Config.cmake.in
new file mode 100644
index 00000000..c485219c
--- /dev/null
+++ b/CMake/Catch2Config.cmake.in
@@ -0,0 +1,10 @@
+@PACKAGE_INIT@
+
+
+# Avoid repeatedly including the targets
+if(NOT TARGET Catch2::Catch2)
+    # Provide path for scripts
+    list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+
+    include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake)
+endif()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e753c6b5..76494710 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,18 +84,29 @@ add_library(Catch2::Catch2 ALIAS Catch2)
 
 set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2")
 
+include(CMakePackageConfigHelpers)
+configure_package_config_file(
+    ${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake
+    INSTALL_DESTINATION
+      ${CATCH_CMAKE_CONFIG_DESTINATION}
+)
+
+
 # create and install an export set for catch target as Catch2::Catch
 install(
   TARGETS
     Catch2
   EXPORT
-    Catch2Config
-  DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    Catch2Targets
+  DESTINATION
+    ${CMAKE_INSTALL_LIBDIR}
 )
 
+
 install(
   EXPORT
-    Catch2Config
+    Catch2Targets
   NAMESPACE
     Catch2::
   DESTINATION
@@ -117,6 +128,7 @@ install(
     
 install(
   FILES 
+    "${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake"
     "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
   DESTINATION
     ${CATCH_CMAKE_CONFIG_DESTINATION}