cmMakefile: Split accessors for include directories and origins.

This commit is contained in:
Stephen Kelly 2015-07-08 23:35:01 +02:00
parent b2de25aded
commit c7b39d06f9
5 changed files with 31 additions and 29 deletions

View File

@ -273,21 +273,18 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
} }
} }
std::vector<cmValueWithOrigin> cmMakefile::GetIncludeDirectoriesEntries() const std::vector<std::string> cmMakefile::GetIncludeDirectoriesEntries() const
{ {
std::vector<cmValueWithOrigin> entries; return this->IncludeDirectoriesEntries;
entries.reserve(this->IncludeDirectoriesEntries.size());
std::vector<cmListFileBacktrace>::const_iterator btIt =
this->IncludeDirectoriesEntryBacktraces.begin();
for(std::vector<std::string>::const_iterator it =
this->IncludeDirectoriesEntries.begin();
it != this->IncludeDirectoriesEntries.end(); ++it, ++btIt)
{
entries.push_back(cmValueWithOrigin(*it, *btIt));
}
return entries;
} }
std::vector<cmListFileBacktrace>
cmMakefile::GetIncludeDirectoriesBacktraces() const
{
return this->IncludeDirectoriesEntryBacktraces;
}
std::vector<std::string> cmMakefile::GetCompileOptionsEntries() const std::vector<std::string> cmMakefile::GetCompileOptionsEntries() const
{ {
return this->CompileOptionsEntries; return this->CompileOptionsEntries;
@ -1942,7 +1939,6 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
std::string entryString = cmJoin(incs, ";"); std::string entryString = cmJoin(incs, ";");
cmValueWithOrigin entry(entryString, lfbt);
this->IncludeDirectoriesEntries.insert(position, entryString); this->IncludeDirectoriesEntries.insert(position, entryString);
this->IncludeDirectoriesEntryBacktraces.insert(btPos, lfbt); this->IncludeDirectoriesEntryBacktraces.insert(btPos, lfbt);
@ -1951,7 +1947,7 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
l != this->Targets.end(); ++l) l != this->Targets.end(); ++l)
{ {
cmTarget &t = l->second; cmTarget &t = l->second;
t.InsertInclude(entry, before); t.InsertInclude(entryString, lfbt, before);
} }
} }

View File

@ -746,7 +746,8 @@ public:
/** Set whether or not to report a CMP0000 violation. */ /** Set whether or not to report a CMP0000 violation. */
void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
std::vector<cmValueWithOrigin> GetIncludeDirectoriesEntries() const; std::vector<std::string> GetIncludeDirectoriesEntries() const;
std::vector<cmListFileBacktrace> GetIncludeDirectoriesBacktraces() const;
std::vector<std::string> GetCompileOptionsEntries() const; std::vector<std::string> GetCompileOptionsEntries() const;
std::vector<cmListFileBacktrace> GetCompileOptionsBacktraces() const; std::vector<cmListFileBacktrace> GetCompileOptionsBacktraces() const;
std::vector<std::string> GetCompileDefinitionsEntries() const; std::vector<std::string> GetCompileDefinitionsEntries() const;

View File

@ -402,13 +402,18 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{ {
// Initialize the INCLUDE_DIRECTORIES property based on the current value // Initialize the INCLUDE_DIRECTORIES property based on the current value
// of the same directory property: // of the same directory property:
const std::vector<cmValueWithOrigin> parentIncludes = const std::vector<std::string> parentIncludes =
this->Makefile->GetIncludeDirectoriesEntries(); this->Makefile->GetIncludeDirectoriesEntries();
const std::vector<cmListFileBacktrace> parentIncludesBts =
this->Makefile->GetIncludeDirectoriesBacktraces();
for (std::vector<cmValueWithOrigin>::const_iterator it std::vector<cmListFileBacktrace>::const_iterator btIt =
= parentIncludes.begin(); it != parentIncludes.end(); ++it) parentIncludesBts.begin();
for (std::vector<std::string>::const_iterator it
= parentIncludes.begin();
it != parentIncludes.end(); ++it, ++btIt)
{ {
this->InsertInclude(*it); this->InsertInclude(*it, *btIt);
} }
const std::set<std::string> parentSystemIncludes = const std::set<std::string> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories(); this->Makefile->GetSystemIncludeDirectories();
@ -421,8 +426,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const std::vector<cmListFileBacktrace> parentOptionsBts = const std::vector<cmListFileBacktrace> parentOptionsBts =
this->Makefile->GetCompileOptionsBacktraces(); this->Makefile->GetCompileOptionsBacktraces();
std::vector<cmListFileBacktrace>::const_iterator btIt = btIt = parentOptionsBts.begin();
parentOptionsBts.begin();
for (std::vector<std::string>::const_iterator it for (std::vector<std::string>::const_iterator it
= parentOptions.begin(); = parentOptions.begin();
it != parentOptions.end(); ++it, ++btIt) it != parentOptions.end(); ++it, ++btIt)
@ -1931,17 +1935,18 @@ void cmTarget::AppendBuildInterfaceIncludes()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::InsertInclude(const cmValueWithOrigin &entry, void cmTarget::InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt,
bool before) bool before)
{ {
cmGeneratorExpression ge(entry.Backtrace); cmGeneratorExpression ge(bt);
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
= before ? this->Internal->IncludeDirectoriesEntries.begin() = before ? this->Internal->IncludeDirectoriesEntries.begin()
: this->Internal->IncludeDirectoriesEntries.end(); : this->Internal->IncludeDirectoriesEntries.end();
this->Internal->IncludeDirectoriesEntries.insert(position, this->Internal->IncludeDirectoriesEntries.insert(position,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry)));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -572,7 +572,8 @@ public:
std::vector<std::string> GetIncludeDirectories( std::vector<std::string> GetIncludeDirectories(
const std::string& config, const std::string& config,
const std::string& language) const; const std::string& language) const;
void InsertInclude(const cmValueWithOrigin &entry, void InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt,
bool before = false); bool before = false);
void InsertCompileOption(std::string const& entry, void InsertCompileOption(std::string const& entry,
cmListFileBacktrace const& bt, cmListFileBacktrace const& bt,

View File

@ -72,8 +72,7 @@ bool cmTargetIncludeDirectoriesCommand
bool prepend, bool system) bool prepend, bool system)
{ {
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertInclude(this->Join(content), lfbt, prepend);
tgt->InsertInclude(entry, prepend);
if (system) if (system)
{ {
tgt->AddSystemIncludeDirectories(content); tgt->AddSystemIncludeDirectories(content);