Skip to content

Commit 56bb3d0

Browse files
OlekRaymondMartchus
authored andcommitted
Find CppUnit2Gtest before searching for CppUnit
Important remarks: * Assertions in helper functions do not always "bubble up" to the test layer, so tests would still fail but not at the line of the `ASSERT`, see https://google.github.io/googletest/advanced.html#assertion-placement * Exiting Assertions are not allowed in constructors or destructors, see https://google.github.io/googletest/faq.html#CtorVsSetUp
1 parent 42966d8 commit 56bb3d0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmake/modules/TestTarget.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ endif ()
1616
if (NOT META_NO_CPP_UNIT)
1717
# allow disabling CppUnit-based tests completely
1818
option(ENABLE_CPP_UNIT "whether CppUnit-based tests should be enabled" ON)
19-
if (NOT ENABLE_CPP_UNIT)
19+
option(ENABLE_CPPUNIT2GTEST "whether to allow CppUnit2Gtest to be used instead of cppunit" ON)
20+
21+
# if user has Ray's adapter layer use it instead
22+
find_package(CppUnit2Gtest QUIET)
23+
if(ENABLE_CPPUNIT2GTEST AND CppUnit2Gtest_FOUND)
24+
find_package(GTest REQUIRED)
25+
set(DETECTED_CPP_UNIT_LIB CppUnit2Gtest::CppUnit2Gtest)
26+
message(STATUS "Using CppUnit2Gtest instead of cppunit")
27+
# otherwise use normal cppunit
28+
elseif (NOT ENABLE_CPP_UNIT)
2029
set(META_HAVE_TESTS NO)
2130
set(TEST_CONFIG_DONE YES)
2231
return()

0 commit comments

Comments
 (0)