CTest is incompatible with XCODE_EMIT_EFFECTIVE_PLATFORM_NAME = ON
When global property XCODE_EMIT_EFFECTIVE_PLATFORM_NAME
is ON (or we are using iOS / tvOS / watchOS where it is ON by default) the CTestTestfile.cmake ends up with an escaped \${EFFECTIVE_PLATFORM_NAME}
in its file path, which is not correct and results in a Could not find executable
error.
e.g. /Users/username/Development/cmake/build/Tests/RunCMake/XcodeProject/XcodeMultiplatform-build/Debug\${EFFECTIVE_PLATFORM_NAME}/main.app/Contents/MacOS/main
I was looking at this as I want to run CTest with iOS and this is the flipside of #23970 (closed) (but they are not the same issue). I cannot test with iOS with the Xcode generator (Makefiles are fine) without fixing one or the other.
The following diff adds a test for this.
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index fde8cc9152..8e31f12648 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -358,6 +358,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5)
run_cmake_command(XcodeMultiplatform-macosx-build ${CMAKE_COMMAND} --build . -- -sdk macosx)
run_cmake_command(XcodeMultiplatform-macosx-install ${CMAKE_COMMAND} --build . --target install -- -sdk macosx DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_macosx)
+ run_cmake_command(XcodeMultiplatform-macosx-test ${CMAKE_COMMAND} --build . --target RUN_TESTS -- -sdk macosx)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)
diff --git a/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake b/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake
index a1064f45dc..7dc7529307 100644
--- a/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake
@@ -12,3 +12,8 @@ add_executable(main main.cpp)
target_link_libraries(main library)
install(TARGETS library ARCHIVE DESTINATION lib)
+
+include(CTest)
+add_test(NAME main
+ COMMAND main
+)