From b2de25adeda1c37c8d626432df25fce7cd2ab032 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 8 Jul 2015 23:17:16 +0200 Subject: [PATCH] cmMakefile: Split accessors for compile options and origins. --- Source/cmMakefile.cxx | 20 ++++++++------------ Source/cmMakefile.h | 3 ++- Source/cmTarget.cxx | 22 ++++++++++++++-------- Source/cmTarget.h | 5 +++-- Source/cmTargetCompileOptionsCommand.cxx | 3 +-- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c705e7dea..8276faa7d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -288,19 +288,15 @@ std::vector cmMakefile::GetIncludeDirectoriesEntries() const return entries; } -std::vector cmMakefile::GetCompileOptionsEntries() const +std::vector cmMakefile::GetCompileOptionsEntries() const { - std::vector entries; - entries.reserve(this->CompileOptionsEntries.size()); - std::vector::const_iterator btIt = - this->CompileOptionsEntryBacktraces.begin(); - for(std::vector::const_iterator it = - this->CompileOptionsEntries.begin(); - it != this->CompileOptionsEntries.end(); ++it, ++btIt) - { - entries.push_back(cmValueWithOrigin(*it, *btIt)); - } - return entries; + return this->CompileOptionsEntries; +} + +std::vector +cmMakefile::GetCompileOptionsBacktraces() const +{ + return this->CompileOptionsEntryBacktraces; } std::vector cmMakefile::GetCompileDefinitionsEntries() const diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e69ce1eea..9b216087d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -747,7 +747,8 @@ public: void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } std::vector GetIncludeDirectoriesEntries() const; - std::vector GetCompileOptionsEntries() const; + std::vector GetCompileOptionsEntries() const; + std::vector GetCompileOptionsBacktraces() const; std::vector GetCompileDefinitionsEntries() const; std::vector GetCompileDefinitionsBacktraces() const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 906517bc1..0aa66cd8b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -416,13 +416,18 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), parentSystemIncludes.end()); - const std::vector parentOptions = + const std::vector parentOptions = this->Makefile->GetCompileOptionsEntries(); + const std::vector parentOptionsBts = + this->Makefile->GetCompileOptionsBacktraces(); - for (std::vector::const_iterator it - = parentOptions.begin(); it != parentOptions.end(); ++it) + std::vector::const_iterator btIt = + parentOptionsBts.begin(); + for (std::vector::const_iterator it + = parentOptions.begin(); + it != parentOptions.end(); ++it, ++btIt) { - this->InsertCompileOption(*it); + this->InsertCompileOption(*it, *btIt); } } @@ -1940,17 +1945,18 @@ void cmTarget::InsertInclude(const cmValueWithOrigin &entry, } //---------------------------------------------------------------------------- -void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, - bool before) +void cmTarget::InsertCompileOption(std::string const& entry, + cmListFileBacktrace const& bt, + bool before) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(bt); std::vector::iterator position = before ? this->Internal->CompileOptionsEntries.begin() : this->Internal->CompileOptionsEntries.end(); this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); + new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9c9867284..ba3bc5a7a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -574,8 +574,9 @@ public: const std::string& language) const; void InsertInclude(const cmValueWithOrigin &entry, bool before = false); - void InsertCompileOption(const cmValueWithOrigin &entry, - bool before = false); + void InsertCompileOption(std::string const& entry, + cmListFileBacktrace const& bt, + bool before = false); void InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt); diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index a85153dd5..8e86f0f79 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -50,7 +50,6 @@ bool cmTargetCompileOptionsCommand bool, bool) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(this->Join(content), lfbt); - tgt->InsertCompileOption(entry); + tgt->InsertCompileOption(this->Join(content), lfbt); return true; }