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, bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
const char *config) 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,28 +1675,14 @@ cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
{ {
this->SystemIncludeDirectories.insert(*li); this->SystemIncludeDirectories.insert(*li);
} }
}
//---------------------------------------------------------------------------- for (cmTargets::iterator l = this->Targets.begin();
bool cmMakefile::IsSystemIncludeDirectory(const char* dir, const char *config) l != this->Targets.end(); ++l)
{ {
for (std::set<cmStdString>::const_iterator cmTarget &t = l->second;
it = this->SystemIncludeDirectories.begin(); t.AddSystemIncludeDirectories(incs);
it != this->SystemIncludeDirectories.end(); ++it)
{
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;
} }
} }
return false;
}
void cmMakefile::AddDefinition(const char* name, const char* value) void cmMakefile::AddDefinition(const char* name, const char* value)
{ {

View File

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

View File

@ -1647,6 +1647,17 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{ {
this->InsertInclude(*it); 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 = const std::vector<cmValueWithOrigin> parentOptions =
this->Makefile->GetCompileOptionsEntries(); 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 void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )

View File

@ -533,7 +533,16 @@ public:
std::string GetDebugGeneratorExpressions(const std::string &value, std::string GetDebugGeneratorExpressions(const std::string &value,
cmTarget::LinkLibraryType llt); 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: 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. * A list of direct dependencies. Use in conjunction with DependencyMap.
*/ */