mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-01 12:18:36 -06:00
Merge topic 'explicit-LANGUAGE-flag'
48aac247e9Compile with explicit language flag when source LANGUAGE property is set2e67a75acdEmbarcadero: Simplify addition of -P flag for C++ Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5522
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -185,7 +185,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") {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user