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

Add pkg-config support

Closes #1032
Commit
c7d9f02d5b723183fb170209e740c7c097c2af04
Author
Martin Hořeňovský ·
Parents
355ab78f4a89

Files · Download .tar.gz

Changes

 CMakeLists.txt           | 15 +++++++++++++++
 catch.pc.in              | 10 ++++++++++
 scripts/releaseCommon.py | 13 +++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17248cfa..f25f47fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
 set(BENCHMARK_DIR ${CATCH_DIR}/projects/Benchmark)
 set(HEADER_DIR ${CATCH_DIR}/include)
+set(CATCH_VERSION_NUMBER 2.0.0)
 
 if(USE_CPP14)
     message(STATUS "Enabling C++14")
@@ -331,3 +332,17 @@ endif() # !NO_SELFTEST
 
 
 install(DIRECTORY "single_include/" DESTINATION "include/catch")
+
+## Provide some pkg-config integration
+# Don't bother on Windows
+if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
+
+    set(PKGCONFIG_INSTALL_DIR
+        "${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
+        CACHE PATH "Path where catch.pc is installed"
+    )
+
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/catch.pc.in ${CMAKE_CURRENT_BINARY_DIR}/catch.pc @ONLY)
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catch.pc DESTINATION ${PKGCONFIG_INSTALL_DIR})
+
+endif()
diff --git a/catch.pc.in b/catch.pc.in
new file mode 100644
index 00000000..de6fdfea
--- /dev/null
+++ b/catch.pc.in
@@ -0,0 +1,10 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+
+Name: Catch
+Description: Testing library for C++
+Requires:
+Version: @CATCH_VERSION_NUMBER@
+Libs:
+Cflags: -I${prefix}/@INCLUDE_INSTALL_DIR@
+
diff --git a/scripts/releaseCommon.py b/scripts/releaseCommon.py
index 6ec175f6..2acd4869 100644
--- a/scripts/releaseCommon.py
+++ b/scripts/releaseCommon.py
@@ -15,6 +15,7 @@ versionPath = os.path.join( rootPath, "internal/catch_version.cpp" )
 readmePath = os.path.join( catchPath, "README.md" )
 conanPath = os.path.join(catchPath, 'conanfile.py')
 conanTestPath = os.path.join(catchPath, 'test_package', 'conanfile.py')
+cmakePath = os.path.join(catchPath, 'CMakeLists.txt')
 
 class Version:
     def __init__(self):
@@ -126,6 +127,17 @@ def updateConanTestFile(version):
     for line in lines:
         f.write( line + "\n" )
 
+def updateCmakeFile(version):
+    cmakeParser = re.compile(r'set(CATCH_VERSION_NUMBER \d+\.\d+\.\d+)')
+    with open(cmakePath, 'r') as file:
+        lines = file.readlines()
+    with open(cmakePath, 'w') as file:
+        for line in lines:
+            if 'set(CATCH_VERSION_NUMBER ' in line:
+                file.write('set(CATCH_VERSION_NUMBER {0})\n'.format(version.getVersionString()))
+            else:
+                file.write(line)
+
 def performUpdates(version):
     # First update version file, so we can regenerate single header and
     # have it ready for upload to wandbox, when updating readme
@@ -134,3 +146,4 @@ def performUpdates(version):
     updateReadmeFile(version)
     updateConanFile(version)
     updateConanTestFile(version)
+    updateCmakeFile(version)