-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to find executable under CMake 3.18 #1984
Comments
Found an interesting difference in the generated diff --git a/_build_cmake317/CTestTestfile.cmake b/_build_cmake318/CTestTestfile.cmake
index d085c28..21ea941 100644
--- a/_build_cmake317/CTestTestfile.cmake
+++ b/_build_cmake318/CTestTestfile.cmake
@@ -4,6 +4,6 @@
#
# This file includes the relevant testing commands required for
# testing this directory and lists subdirectories to be tested as well.
-add_test("test_yes:all is good" "/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build/test_yes" "all is good")
-set_tests_properties("test_yes:all is good" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran" LABELS "test_yes" _BACKTRACE_TRIPLES "/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/external/catch2/contrib/ParseAndAddCatchTests.cmake;193;add_test;/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/external/catch2/contrib/ParseAndAddCatchTests.cmake;222;ParseAndAddCatchTests_ParseFile;/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/CMakeLists.txt;18;ParseAndAddCatchTests;/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/CMakeLists.txt;0;")
+add_test(""test_yes:all is good"" "/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build/test_yes" "all is good")
+set_tests_properties(""test_yes:all is good"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran" LABELS "test_yes" _BACKTRACE_TRIPLES "/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/external/catch2/contrib/ParseAndAddCatchTests.cmake;193;add_test;/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/external/catch2/contrib/ParseAndAddCatchTests.cmake;222;ParseAndAddCatchTests_ParseFile;/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/CMakeLists.txt;18;ParseAndAddCatchTests;/home/nero/repos/external/Catch2_minimial_example_cmake_3_18/CMakeLists.txt;0;")
subdirs("external/catch2") Another cosmetic difference (unneeded diff --git a/_build_cmake317/Makefile b/_build_cmake318/Makefile
index 1730852..3981678 100644
--- a/_build_cmake317/Makefile
+++ b/_build_cmake318/Makefile
@@ -1,5 +1,5 @@
# CMAKE generated file: DO NOT EDIT!
-# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+# Generated by "Unix Makefiles" Generator, CMake Version 3.18
# Default target executed when no arguments are given to make.
default_target: all
@@ -43,10 +43,9 @@ default_target: all
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
-# Suppress display of executed commands.
+#Suppress display of executed commands.
$(VERBOSE).SILENT:
-
# A target that is always out of date.
cmake_force:
@@ -111,7 +110,7 @@ test/fast: test
# The main all target
all: cmake_check_build_system
- $(CMAKE_COMMAND) -E cmake_progress_start /home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build/CMakeFiles /home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build/CMakeFiles/progress.marks
+ $(CMAKE_COMMAND) -E cmake_progress_start /home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build/CMakeFiles /home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build//CMakeFiles/progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/nero/repos/external/Catch2_minimial_example_cmake_3_18/_build/CMakeFiles 0
.PHONY : all |
created cmake upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/20965 |
If I apply the following patch then CMake 3.18.0 works as expected, but fails on CMake 3.17.3 --- a/external/catch2/contrib/ParseAndAddCatchTests.cmake
+++ b/external/catch2/contrib/ParseAndAddCatchTests.cmake
@@ -190,23 +190,23 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
string(REPLACE "," "\\," Name ${Name})
# 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() |
got a workaround working on both CMake 3.18 and CMake 3.17.3, --- a/external/catch2/contrib/ParseAndAddCatchTests.cmake
+++ b/external/catch2/contrib/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() |
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: catchorg#1984
relevant change in documentation https://cmake.org/cmake/help/v3.18/command/add_test.html - Adds a test called <name>. The test name may not contain spaces, quotes, or other characters special in CMake syntax. The options are:
+ Adds a test called <name>. The test name may contain arbitrary characters except for double-quotes. However, if it contains spaces or semicolons it must be enclosed in double-quotes. The options are: |
got a response on the CMake-Issue by Brad King
|
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: #1984
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: #1984
Describe the bug
When upgrading CMake to 3.18.0 Catch2 tests are not found anymore. They get compiled, but cannot be executed. With CMake 3.17.3 everything works as expected
Expected behavior
test executables should be found and executed, also on CMake 3.18.0
Reproduction steps
Steps to reproduce the bug.
install CMake 3.18.0
create a minimal example using Catch2, for example https://github.com/NeroBurner/Catch2_minimial_example_cmake_3_18
cmake -H. -B_build cmkae --build _build cmake --build _build --target test
Log with CMake 3.18.0
Logs with CMake 3.17.3
Platform information:
Additional context
edit: cmake upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/20965
The text was updated successfully, but these errors were encountered: