diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2015-04-04 22:13:45 +0200 |
---|---|---|
committer | Gregor Jasny <gjasny@googlemail.com> | 2015-04-04 22:13:45 +0200 |
commit | dfd6f1f2904ca577743adb5f86f1722359723a0b (patch) | |
tree | c821c336f114ceadc09f066855a5e436222a084d | |
parent | c6624cfdc1fe9c7c53ad9ed06da759df803aef71 (diff) | |
download | cmake-dfd6f1f2904ca577743adb5f86f1722359723a0b.tar.gz |
Xcode: Also quote strings containing // (#15487)
Otherwise those will be interpreted as start of a comment
Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
5 files changed, 12 insertions, 0 deletions
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 3302a8de41..5a90fd96f6 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -242,6 +242,7 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) // considered special by the Xcode project file parser. bool needQuote = (String.empty() || + String.find("//") != String.npos || String.find_first_of(" <>.+-=@$[],") != String.npos); const char* quote = needQuote? "\"" : ""; diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 03d3cd3a93..b7de614799 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(XcodeFileType) run_cmake(XcodeAttributeGenex) run_cmake(XcodeAttributeGenexError) +run_cmake(XcodeObjectNeedsQuote) if (NOT XCODE_VERSION VERSION_LESS 6) run_cmake(XcodePlatformFrameworks) endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote-check.cmake b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote-check.cmake new file mode 100644 index 0000000000..be7d96ab65 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote-check.cmake @@ -0,0 +1,7 @@ +set(expect "path = \"") +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeObjectNeedsQuote.xcodeproj/project.pbxproj actual + REGEX "path = [^;]*someFileWithoutSpecialChars[^;]*;" LIMIT_COUNT 1) +if(NOT "${actual}" MATCHES "${expect}") + message(SEND_ERROR "The actual project contains the line:\n ${actual}\n" + "which does not match expected regex:\n ${expect}\n") +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote.cmake b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote.cmake new file mode 100644 index 0000000000..ecc56abb7d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_library(some /${CMAKE_CURRENT_SOURCE_DIR}/someFileWithoutSpecialChars) +set_property(SOURCE /${CMAKE_CURRENT_SOURCE_DIR}/someFileWithoutSpecialChars PROPERTY LANGUAGE C) diff --git a/Tests/RunCMake/XcodeProject/someFileWithoutSpecialChars b/Tests/RunCMake/XcodeProject/someFileWithoutSpecialChars new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/someFileWithoutSpecialChars |