mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-08 23:29:53 +01:00
Fix CMake add test helper for CMake 3.18.0
With CMake 3.18.0 the `add_test(NAME)` handling changed. The escaped double quotes confuse the new call. Work around this upstream change. fixes: https://github.com/catchorg/Catch2/issues/1984
This commit is contained in:
parent
7f21cc6c55
commit
229cc4823c
@ -189,24 +189,29 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
|
|||||||
# Escape commas in the test spec
|
# Escape commas in the test spec
|
||||||
string(REPLACE "," "\\," Name ${Name})
|
string(REPLACE "," "\\," Name ${Name})
|
||||||
|
|
||||||
|
# Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were neccessary,
|
||||||
|
# beginning with CMake 3.18.0 the escaped double quotes confuse the call
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS "3.18")
|
||||||
|
set(CTestName "\"${CTestName}\"")
|
||||||
|
endif()
|
||||||
# Add the test and set its properties
|
# Add the test and set its properties
|
||||||
add_test(NAME "\"${CTestName}\"" COMMAND ${OptionalCatchTestLauncher} $<TARGET_FILE:${TestTarget}> ${Name} ${AdditionalCatchParameters})
|
add_test(NAME "${CTestName}" COMMAND ${OptionalCatchTestLauncher} $<TARGET_FILE:${TestTarget}> ${Name} ${AdditionalCatchParameters})
|
||||||
# Old CMake versions do not document VERSION_GREATER_EQUAL, so we use VERSION_GREATER with 3.8 instead
|
# Old CMake versions do not document VERSION_GREATER_EQUAL, so we use VERSION_GREATER with 3.8 instead
|
||||||
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8")
|
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8")
|
||||||
ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property")
|
ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property")
|
||||||
set_tests_properties("\"${CTestName}\"" PROPERTIES DISABLED ON)
|
set_tests_properties("${CTestName}" PROPERTIES DISABLED ON)
|
||||||
else()
|
else()
|
||||||
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
set_tests_properties("${CTestName}" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
||||||
LABELS "${Labels}")
|
LABELS "${Labels}")
|
||||||
endif()
|
endif()
|
||||||
set_property(
|
set_property(
|
||||||
TARGET ${TestTarget}
|
TARGET ${TestTarget}
|
||||||
APPEND
|
APPEND
|
||||||
PROPERTY ParseAndAddCatchTests_TESTS "\"${CTestName}\"")
|
PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}")
|
||||||
set_property(
|
set_property(
|
||||||
SOURCE ${SourceFile}
|
SOURCE ${SourceFile}
|
||||||
APPEND
|
APPEND
|
||||||
PROPERTY ParseAndAddCatchTests_TESTS "\"${CTestName}\"")
|
PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user