Store system include directories in the cmTarget.

Entries from the cmMakefile are processed and maintained similarly
to other include directories. The include_directories(SYSTEM)
signature affects all following targets, and all prior targets
in the same makefile.
This commit is contained in:
Stephen Kelly 2013-07-01 22:55:25 +02:00
parent f1fcbe3fde
commit 83498d4135
5 changed files with 66 additions and 19 deletions

View File

@ -51,7 +51,23 @@ const char *cmGeneratorTarget::GetProperty(const char *prop)
bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
const char *config)
{
return this->Makefile->IsSystemIncludeDirectory(dir, config);
for (std::set<cmStdString>::const_iterator
it = this->Target->GetSystemIncludeDirectories().begin();
it != this->Target->GetSystemIncludeDirectories().end(); ++it)
{
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
std::vector<std::string> incs;
cmSystemTools::ExpandListArgument(ge.Parse(*it)
->Evaluate(this->Makefile,
config, false), incs);
if (std::find(incs.begin(), incs.end(), dir) != incs.end())
{
return true;
}
}
return false;
}
//----------------------------------------------------------------------------

View File

@ -1675,27 +1675,13 @@ cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
{
this->SystemIncludeDirectories.insert(*li);
}
}
//----------------------------------------------------------------------------
bool cmMakefile::IsSystemIncludeDirectory(const char* dir, const char *config)
{
for (std::set<cmStdString>::const_iterator
it = this->SystemIncludeDirectories.begin();
it != this->SystemIncludeDirectories.end(); ++it)
for (cmTargets::iterator l = this->Targets.begin();
l != this->Targets.end(); ++l)
{
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
std::vector<std::string> incs;
cmSystemTools::ExpandListArgument(ge.Parse(*it)
->Evaluate(this, config, false), incs);
if (std::find(incs.begin(), incs.end(), dir) != incs.end())
{
return true;
cmTarget &t = l->second;
t.AddSystemIncludeDirectories(incs);
}
}
return false;
}
void cmMakefile::AddDefinition(const char* name, const char* value)

View File

@ -875,6 +875,9 @@ public:
bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; }
void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; }
std::set<cmStdString> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(const char* name, cmTarget& target);

View File

@ -1647,6 +1647,17 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{
this->InsertInclude(*it);
}
const std::set<cmStdString> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories();
for (std::set<cmStdString>::const_iterator it
= parentSystemIncludes.begin();
it != parentSystemIncludes.end(); ++it)
{
this->SystemIncludeDirectories.insert(*it);
}
const std::vector<cmValueWithOrigin> parentOptions =
this->Makefile->GetCompileOptionsEntries();
@ -2522,6 +2533,28 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
}
//----------------------------------------------------------------------------
void
cmTarget::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
{
for(std::set<cmStdString>::const_iterator li = incs.begin();
li != incs.end(); ++li)
{
this->SystemIncludeDirectories.insert(*li);
}
}
//----------------------------------------------------------------------------
void
cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs)
{
for(std::vector<std::string>::const_iterator li = incs.begin();
li != incs.end(); ++li)
{
this->SystemIncludeDirectories.insert(*li);
}
}
//----------------------------------------------------------------------------
void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )

View File

@ -533,7 +533,16 @@ public:
std::string GetDebugGeneratorExpressions(const std::string &value,
cmTarget::LinkLibraryType llt);
void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
std::set<cmStdString> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
private:
// The set of include directories that are marked as system include
// directories.
std::set<cmStdString> SystemIncludeDirectories;
/**
* A list of direct dependencies. Use in conjunction with DependencyMap.
*/