diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-06-01 17:45:13 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2020-06-09 23:41:20 (GMT) |
commit | 74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011 (patch) | |
tree | 4574908690751173637e9ef498c495f6a1501e63 /Source | |
parent | 457170a476ca3ff3b5db80360a7fd8202ac31e91 (diff) | |
download | CMake-74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011.zip CMake-74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011.tar.gz CMake-74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011.tar.bz2 |
Explicitly specify language flag when source LANGUAGE property is set
Fixes: #14516, #20716
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 11 |
4 files changed, 32 insertions, 1 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 613a943..3e265a0 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -349,6 +349,13 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( if (language.empty()) { language = "C"; } + + // explicitly add the explicit language flag before any other flag + // this way backwards compatibility with user flags is maintained + if (source->GetProperty("LANGUAGE")) { + lg->AppendFeatureOptions(flags, language, "EXPLICIT_LANGUAGE"); + } + std::string const& config = lg->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index a5ce5d1..4d589ed 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -819,6 +819,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( default: break; } + + // explicitly add the explicit language flag before any other flag + // this way backwards compatibility with user flags is maintained + if (sf->GetProperty("LANGUAGE")) { + this->CurrentLocalGenerator->AppendFeatureOptions(flags, lang, + "EXPLICIT_LANGUAGE"); + } + const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) { lg->AppendFlags(flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS)); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 8396fa3..6887569 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -532,6 +532,13 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Build the set of compiler flags. std::string flags; + // explicitly add the explicit language flag before any other flag + // this way backwards compatibility with user flags is maintained + if (source.GetProperty("LANGUAGE")) { + this->LocalGenerator->AppendFeatureOptions(flags, lang, + "EXPLICIT_LANGUAGE"); + } + // Add language-specific flags. std::string langFlags = cmStrCat("$(", lang, "_FLAGS", filterArch, ")"); this->LocalGenerator->AppendFlags(flags, langFlags); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d406c99..0c7591a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -188,7 +188,16 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( } } - std::string flags = this->GetFlags(language, config, filterArch); + std::string flags; + // explicitly add the explicit language flag before any other flag + // this way backwards compatibility with user flags is maintained + if (source->GetProperty("LANGUAGE")) { + this->LocalGenerator->AppendFeatureOptions(flags, language, + "EXPLICIT_LANGUAGE"); + flags += " "; + } + + flags += this->GetFlags(language, config, filterArch); // Add Fortran format flags. if (language == "Fortran") { |