summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-04-14 12:15:30 (GMT)
committerBrad King <brad.king@kitware.com>2020-04-15 12:34:18 (GMT)
commitaf7de05853f9ced4703b7dc470f7eb475f1ede9c (patch)
tree528954403a46eec04a24492f66c5c46bdf1d2b0a /Source/cmMakefileTargetGenerator.cxx
parent1639ee70ef7986c4c6ad72db1b2552bcaa5b88fa (diff)
downloadCMake-af7de05853f9ced4703b7dc470f7eb475f1ede9c.zip
CMake-af7de05853f9ced4703b7dc470f7eb475f1ede9c.tar.gz
CMake-af7de05853f9ced4703b7dc470f7eb475f1ede9c.tar.bz2
Makefiles: Do not use '\#' escape sequence with Windows-style make tools
Since commit fbf7a92975 (Makefile: Handle '#' in COMPILE_OPTIONS, 2014-08-12, v3.1.0-rc1~174^2) we escape `#` as `\#` in `flags.make` variable assignments so that they are not treated as a comment. Windows-style make tools like NMake do not interpret backslashes in that way. Other means will be needed to handle `#` in contexts where it is even possible. The test suite is not covering this for NMake anyway, and actually has a workaround in `Tests/TryCompile` for the old behavior, which we can now update.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5bb4c57..dc3a2a1 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -341,12 +341,16 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
<< "\n";
}
+ bool const escapeOctothorpe = this->GlobalGenerator->CanEscapeOctothorpe();
+
for (std::string const& language : languages) {
std::string defines = this->GetDefines(language, this->GetConfigName());
std::string includes = this->GetIncludes(language, this->GetConfigName());
- // Escape comment characters so they do not terminate assignment.
- cmSystemTools::ReplaceString(defines, "#", "\\#");
- cmSystemTools::ReplaceString(includes, "#", "\\#");
+ if (escapeOctothorpe) {
+ // Escape comment characters so they do not terminate assignment.
+ cmSystemTools::ReplaceString(defines, "#", "\\#");
+ cmSystemTools::ReplaceString(includes, "#", "\\#");
+ }
*this->FlagFileStream << language << "_DEFINES = " << defines << "\n\n";
*this->FlagFileStream << language << "_INCLUDES = " << includes << "\n\n";
@@ -357,7 +361,9 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
for (const std::string& arch : architectures) {
std::string flags =
this->GetFlags(language, this->GetConfigName(), arch);
- cmSystemTools::ReplaceString(flags, "#", "\\#");
+ if (escapeOctothorpe) {
+ cmSystemTools::ReplaceString(flags, "#", "\\#");
+ }
*this->FlagFileStream << language << "_FLAGS" << arch << " = " << flags
<< "\n\n";
}