Skip to content

Update Catch2 to v2.13.9, resolving a build error with GCC 11#75

Open
jpetso wants to merge 1 commit intotplgy:masterfrom
jpetso:catch2-v2.13.9
Open

Update Catch2 to v2.13.9, resolving a build error with GCC 11#75
jpetso wants to merge 1 commit intotplgy:masterfrom
jpetso:catch2-v2.13.9

Conversation

@jpetso
Copy link
Copy Markdown
Collaborator

@jpetso jpetso commented Aug 21, 2022

Fixes #74

@cybaol
Copy link
Copy Markdown

cybaol commented Mar 5, 2024

I think it's time to Catch2 v3.

@anthraxx
Copy link
Copy Markdown

hitting this issue as well during distro packaging and we'd need support for catch v3. Is this project dead?

@jpetso
Copy link
Copy Markdown
Collaborator Author

jpetso commented May 27, 2024

hitting this issue as well during distro packaging and we'd need support for catch v3. Is this project dead?

Possibly, I'm still looking at incoming PR/issue activity but haven't really taken the time to modernize the surrounding build infrastructure such as tests and CMake. Sorry. Found it more important/rewarding to work on KDE software instead. But also, I'll review any pull requests so if you're willing to contribute a patch, it can go in on short notice.

@jpetso
Copy link
Copy Markdown
Collaborator Author

jpetso commented May 27, 2024

But also it's the Arch project leader personally, so maybe I can make an exception and take some time for this. Love your distro, have been using it on both my laptop and desktop for years!

@jpetso
Copy link
Copy Markdown
Collaborator Author

jpetso commented Aug 21, 2024

Hi, I'm sorry that this issue has still not seen any movement. As a workaround, consider building with -D CPPCODEC_BUILD_TESTING=0 to exclude tests from the build.

@anthraxx
Copy link
Copy Markdown

anthraxx commented Aug 21, 2024 via email

@loqs
Copy link
Copy Markdown

loqs commented Apr 14, 2026

@jpetso updating to catch2 v3 should be relatively simple (does the following work for you):
Switch from pkg_check_modules to find_package this will make linking with V3 easier:

--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,11 +1,7 @@
-find_package(PkgConfig)
-if(PKG_CONFIG_FOUND)
-    pkg_check_modules(CATCH2 catch2)
-endif()
+find_package(Catch2 CONFIG QUIET)
 
-if(CATCH2_FOUND)
+if(Catch2_FOUND)
     message(STATUS "Found system Catch2, not using bundled version")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATCH2_CFLAGS}")
 else()
     message(STATUS "Did NOT find system Catch2, instead using bundled version")
     include_directories(${CMAKE_CURRENT_SOURCE_DIR}/catch/single_include)
  • Update test/catch submodule to v3.14.0
  • Update test/CMakeLists.txt to use Catch v3's CMake integration via add_subdirectory(catch) and link against Catch2::Catch2WithMain
  • Update test/test_cppcodec.cpp to use catch_all.hpp instead of catch.hpp
  • C++ standard will be upgrade to C++ 14 for the tests as required by Catch v3
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 39fceba..10abce2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -8,13 +8,13 @@ if(CATCH2_FOUND)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATCH2_CFLAGS}")
 else()
     message(STATUS "Did NOT find system Catch2, instead using bundled version")
-    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/catch/single_include)
+    add_subdirectory(catch)
 endif()
 
 add_compile_options(${CPPCODEC_PRIVATE_COMPILE_OPTIONS})
 
 add_executable(test_cppcodec test_cppcodec.cpp)
-target_link_libraries(test_cppcodec cppcodec)
+target_link_libraries(test_cppcodec cppcodec Catch2::Catch2WithMain)
 add_test(NAME cppcodec COMMAND test_cppcodec)
 
 add_executable(benchmark_cppcodec benchmark_cppcodec.cpp)
diff --git a/test/catch b/test/catch
index 15cf3ca..b670de4 160000
--- a/test/catch
+++ b/test/catch
@@ -1 +1 @@
-Subproject commit 15cf3caaceb21172ea42a24e595a2eb58c3ec960
+Subproject commit b670de4fe12ac7c5e858b7de3a14fb4bd18c760e
diff --git a/test/test_cppcodec.cpp b/test/test_cppcodec.cpp
index d7e50bc..1d6662b 100644
--- a/test/test_cppcodec.cpp
+++ b/test/test_cppcodec.cpp
@@ -22,7 +22,7 @@
  */
 
 #define CATCH_CONFIG_MAIN
-#include <catch2/catch.hpp>
+#include <catch2/catch_all.hpp>
 
 #include <cppcodec/base32_crockford.hpp>
 #include <cppcodec/base32_hex.hpp>

Reduction to minimal headers from catch_all.hpp:

diff --git a/test/test_cppcodec.cpp b/test/test_cppcodec.cpp
index 1d6662b..0577fb9 100644
--- a/test/test_cppcodec.cpp
+++ b/test/test_cppcodec.cpp
@@ -22,7 +22,7 @@
  */
 
 #define CATCH_CONFIG_MAIN
-#include <catch2/catch_all.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include <cppcodec/base32_crockford.hpp>
 #include <cppcodec/base32_hex.hpp>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Catch2 v2.3.0 doesn't compile with gcc11

4 participants