summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx5
-rw-r--r--Source/cmGeneratorTarget.cxx24
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx5
-rw-r--r--Source/cmMakefileTargetGenerator.cxx4
-rw-r--r--Source/cmNinjaTargetGenerator.cxx10
-rw-r--r--Source/cmPolicies.h9
7 files changed, 57 insertions, 3 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 7c36144..249dfaf 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -349,6 +349,11 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
if (language.empty()) {
language = "C";
}
+
+ // Explicitly add the explicit language flag before any other flag
+ // so user flags can override it.
+ gtgt->AddExplicitLanguageFlags(flags, *source);
+
std::string const& config =
lg->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 4a79a3d..12f8e44 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3155,6 +3155,30 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config,
}
}
+void cmGeneratorTarget::AddExplicitLanguageFlags(std::string& flags,
+ cmSourceFile const& sf) const
+{
+ cmProp lang = sf.GetProperty("LANGUAGE");
+ if (!lang) {
+ return;
+ }
+
+ switch (this->GetPolicyStatusCMP0119()) {
+ case cmPolicies::WARN:
+ case cmPolicies::OLD:
+ // The OLD behavior is to not add explicit language flags.
+ return;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ // The NEW behavior is to add explicit language flags.
+ break;
+ }
+
+ this->LocalGenerator->AppendFeatureOptions(flags, *lang,
+ "EXPLICIT_LANGUAGE");
+}
+
void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const
{
const std::string& property = this->GetSafeProperty("CUDA_ARCHITECTURES");
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 2517b72..cb312ad 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -447,6 +447,9 @@ public:
void GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const;
+ void AddExplicitLanguageFlags(std::string& flags,
+ cmSourceFile const& sf) const;
+
void AddCUDAArchitectureFlags(std::string& flags) const;
void AddCUDAToolkitFlags(std::string& flags) const;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 78c7538..17d1790 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -938,6 +938,11 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
default:
break;
}
+
+ // Explicitly add the explicit language flag before any other flag
+ // so user flags can override it.
+ gtgt->AddExplicitLanguageFlags(flags, *sf);
+
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 155a097..ee47e46 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -622,6 +622,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Build the set of compiler flags.
std::string flags;
+ // Explicitly add the explicit language flag before any other flag
+ // so user flags can override it.
+ this->GeneratorTarget->AddExplicitLanguageFlags(flags, source);
+
// 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 4ac08e0..86cbf80 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -183,7 +183,15 @@ 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
+ // so user flags can override it.
+ this->GeneratorTarget->AddExplicitLanguageFlags(flags, *source);
+
+ if (!flags.empty()) {
+ flags += " ";
+ }
+ flags += this->GetFlags(language, config, filterArch);
// Add Fortran format flags.
if (language == "Fortran") {
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 646e226..0d04f7a 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -352,7 +352,11 @@ class cmMakefile;
SELECT( \
POLICY, CMP0118, \
"The GENERATED source file property is now visible in all directories.", \
- 3, 20, 0, cmPolicies::WARN)
+ 3, 20, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0119, \
+ "LANGUAGE source file property explicitly compiles as specified " \
+ "language.", \
+ 3, 20, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -387,7 +391,8 @@ class cmMakefile;
F(CMP0105) \
F(CMP0108) \
F(CMP0112) \
- F(CMP0113)
+ F(CMP0113) \
+ F(CMP0119)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies