cmake: Explicitly search for Catch2 version 3

The current CMakeLists block

find_package(Catch2)
if(Catch2_FOUND)
  target_link_libraries(test_suite Catch2::Catch2WithMain)
  include(CTest)
  include(Catch)
  catch_discover_tests(test_suite)
endif()

would search for any Catch2 version, but later tries to link against
Catch2 version 3 (Catch2WithMain). This means the block would fail on
systems that have Catch2 version 2 installed, but not Catch2 version
3. Fix that by requesting Catch2 version 3 when invoking
find_package().

Link: https://bugs.gentoo.org/969522
This commit is contained in:
Florian Schmaus
2026-02-10 08:53:34 +01:00
parent bf958d0e34
commit 3d321c7d92
+1 -1
View File
@@ -296,7 +296,7 @@ endforeach()
#
## Catch unit test framework
#
find_package(Catch2)
find_package(Catch2 3)
if(Catch2_FOUND)
target_link_libraries(test_suite Catch2::Catch2WithMain)
include(CTest)