summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-06-10 16:04:58 (GMT)
committerBrad King <brad.king@kitware.com>2016-06-17 18:49:38 (GMT)
commit3c488ce89955d00785bb4637c87b960da6c55ec8 (patch)
treeab23337d74ad31f05734257251e8741f52ac126f /Source
parent5467e7945d46f5f8540a6e11933c9b6b584036a2 (diff)
downloadCMake-3c488ce89955d00785bb4637c87b960da6c55ec8.zip
CMake-3c488ce89955d00785bb4637c87b960da6c55ec8.tar.gz
CMake-3c488ce89955d00785bb4637c87b960da6c55ec8.tar.bz2
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommonTargetGenerator.cxx33
-rw-r--r--Source/cmLocalGenerator.cxx27
-rw-r--r--Source/cmLocalGenerator.h3
3 files changed, 32 insertions, 31 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index aa7f5c0..101093d 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -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;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a0263e4..e2e7aa1 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -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)
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index d04a723..66fbe01 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -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,