diff options
| author | Reinhold Gschweicher | 2020-07-16 11:45:38 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-07-26 15:15:50 +0200 |
| commit | 95c0c88d84e61121d3f5a725584695d44ded13bc (patch) | |
| tree | 40aa0a0d15106674ee63ff0fd7bb168afb2b1ff8 | |
| parent | 6efeecc1796f383a88919eacf7487c53f388b7dd (diff) | |
| download | catch3-95c0c88d84e61121d3f5a725584695d44ded13bc.tar.gz | |
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
| -rw-r--r-- | extras/ParseAndAddCatchTests.cmake | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/extras/ParseAndAddCatchTests.cmake b/extras/ParseAndAddCatchTests.cmake index 3c551f07..80a39938 100644 --- a/extras/ParseAndAddCatchTests.cmake +++ b/extras/ParseAndAddCatchTests.cmake @@ -189,24 +189,29 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget) # Escape commas in the test spec 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_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 if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8") ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property") - set_tests_properties("\"${CTestName}\"" PROPERTIES DISABLED ON) + set_tests_properties("${CTestName}" PROPERTIES DISABLED ON) 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}") endif() set_property( TARGET ${TestTarget} APPEND - PROPERTY ParseAndAddCatchTests_TESTS "\"${CTestName}\"") + PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}") set_property( SOURCE ${SourceFile} APPEND - PROPERTY ParseAndAddCatchTests_TESTS "\"${CTestName}\"") + PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}") endif() |