cmLocalGenerator: Adopt target compile flag generation

Factor the flag generation out of cmCommonTargetGenerator::GetFlags
into a new cmLocalGenerator::GetTargetCompileFlags method.
This will allow it to be used without a target generator available.
This commit is contained in:
Tobias Hunger 2016-06-10 18:04:58 +02:00 committed by Brad King
parent 5467e7945d
commit 3c488ce899
3 changed files with 32 additions and 31 deletions

View File

@ -120,38 +120,9 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
if (i == this->FlagsByLanguage.end()) {
std::string flags;
const char* lang = l.c_str();
// Add language feature flags.
this->AddFeatureFlags(flags, lang);
this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
lang, this->ConfigName);
// Fortran-specific flags computed for this target.
if (l == "Fortran") {
this->LocalGenerator->AppendFlags(
flags, this->LocalGenerator->GetTargetFortranFlags(
this->GeneratorTarget, this->ConfigName));
}
this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
this->ConfigName);
this->LocalGenerator->AddVisibilityPresetFlags(
flags, this->GeneratorTarget, lang);
// Append old-style preprocessor definition flags.
this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
// Add framework directory flags.
this->LocalGenerator->AppendFlags(
flags, this->LocalGenerator->GetFrameworkFlags(l, this->ConfigName,
this->GeneratorTarget));
// Add target-specific flags.
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
this->ConfigName);
this->LocalGenerator->GetTargetCompileFlags(this->GeneratorTarget,
this->ConfigName, l, flags);
ByLanguageMap::value_type entry(l, flags);
i = this->FlagsByLanguage.insert(entry).first;

View File

@ -1272,6 +1272,33 @@ void cmLocalGenerator::GetTargetFlags(
}
}
void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target,
std::string const& config,
std::string const& lang,
std::string& flags)
{
cmMakefile* mf = this->GetMakefile();
// Add language-specific flags.
this->AddLanguageFlags(flags, lang, config);
if (target->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) {
this->AppendFeatureOptions(flags, lang, "IPO");
}
this->AddArchitectureFlags(flags, target, lang, config);
if (lang == "Fortran") {
this->AppendFlags(flags, this->GetTargetFortranFlags(target, config));
}
this->AddCMP0018Flags(flags, target, lang, config);
this->AddVisibilityPresetFlags(flags, target, lang);
this->AppendFlags(flags, mf->GetDefineFlags());
this->AppendFlags(flags, this->GetFrameworkFlags(lang, config, target));
this->AddCompileOptions(flags, target, lang, config);
}
static std::string GetFrameworkFlags(const std::string& lang,
const std::string& config,
cmGeneratorTarget* target)

View File

@ -317,6 +317,9 @@ public:
void GetTargetDefines(cmGeneratorTarget const* target,
std::string const& config, std::string const& lang,
std::set<std::string>& defines) const;
void GetTargetCompileFlags(cmGeneratorTarget* target,
std::string const& config,
std::string const& lang, std::string& flags);
std::string GetFrameworkFlags(std::string const& l,
std::string const& config,