cmGlobalXCodeGenerator: Re-implement legacy makefile path escaping
Apply commit d74e651b78 (Makefiles: Re-implement makefile target path
escaping and quoting, 2020-04-10, v3.18.0-rc1~334^2~1) to the Xcode
generator's legacy Makefile generation. This adds support for '#'.
However, since we use '$(VAR)' placeholders, do not escape '$'.
Issue: #25604
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d7b6f9f..aa948a5 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -267,7 +267,21 @@
namespace {
std::string ConvertToMakefilePath(std::string const& path)
{
- return cmSystemTools::ConvertToOutputPath(path);
+ std::string result;
+ result.reserve(path.size());
+ for (char c : path) {
+ switch (c) {
+ case '\\':
+ case ' ':
+ case '#':
+ result.push_back('\\');
+ CM_FALLTHROUGH;
+ default:
+ result.push_back(c);
+ break;
+ }
+ }
+ return result;
}
}