summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-07-02 14:30:10 +0200
committerBrad King <brad.king@kitware.com>2013-07-16 13:44:57 -0400
commit9cf3547e1cd56d42bc96c3dc3adf9f745faea5ee (patch)
treeea220c1949611ac1977841ea77ff22bcac061497 /Source
parent1925cffa083bcbe3c54b8a0f2c63dc96f5168db0 (diff)
downloadcmake-9cf3547e1cd56d42bc96c3dc3adf9f745faea5ee.tar.gz
Add the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property.
Unlike other target properties, this does not have a corresponding non-INTERFACE variant. This allows propagation of system attribute on include directories from link dependents.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportInstallFileGenerator.cxx4
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx8
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx44
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmGlobalGenerator.cxx11
-rw-r--r--Source/cmTarget.cxx44
-rw-r--r--Source/cmTarget.h3
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx17
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.h8
11 files changed, 133 insertions, 14 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index a966b16051..43b17c6027 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -126,6 +126,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateIncludeDirectoriesInterface(te,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
+ te,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
te,
cmGeneratorExpression::InstallInterface,
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 5b79e35310..d04e195425 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -172,6 +172,14 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingIncludeDirectories() const
}
//----------------------------------------------------------------------------
+bool
+cmGeneratorExpressionDAGChecker::EvaluatingSystemIncludeDirectories() const
+{
+ const char *prop = this->Property.c_str();
+ return strcmp(prop, "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") == 0;
+}
+
+//----------------------------------------------------------------------------
bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const
{
const char *prop = this->Property.c_str();
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 95d466ae3b..f0524f2905 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -18,11 +18,13 @@
#define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \
F(EvaluatingIncludeDirectories) \
+ F(EvaluatingSystemIncludeDirectories) \
F(EvaluatingCompileDefinitions) \
F(EvaluatingCompileOptions)
#define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \
F(INTERFACE_INCLUDE_DIRECTORIES) \
+ F(INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) \
F(INTERFACE_COMPILE_DEFINITIONS) \
F(INTERFACE_COMPILE_OPTIONS)
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 05bbc1ce81..53fb35d6e3 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -879,6 +879,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
interfacePropertyName = "INTERFACE_INCLUDE_DIRECTORIES";
}
+ else if (propertyName == "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")
+ {
+ interfacePropertyName = "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES";
+ }
else if (propertyName == "INTERFACE_COMPILE_DEFINITIONS"
|| propertyName == "COMPILE_DEFINITIONS"
|| strncmp(propertyName.c_str(), "COMPILE_DEFINITIONS_", 20) == 0)
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 9167b25a3a..5ce0e6be15 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -51,21 +51,43 @@ const char *cmGeneratorTarget::GetProperty(const char *prop)
bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
const char *config)
{
- for (std::set<cmStdString>::const_iterator
- it = this->Target->GetSystemIncludeDirectories().begin();
- it != this->Target->GetSystemIncludeDirectories().end(); ++it)
+ std::string config_upper;
+ if(config && *config)
{
- cmListFileBacktrace lfbt;
- cmGeneratorExpression ge(lfbt);
+ config_upper = cmSystemTools::UpperCase(config);
+ }
+
+ typedef std::map<std::string, std::vector<std::string> > IncludeCacheType;
+ IncludeCacheType::iterator iter =
+ this->SystemIncludesCache.find(config_upper);
- 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())
+ if (iter == this->SystemIncludesCache.end())
+ {
+ std::vector<std::string> result;
+ for (std::set<cmStdString>::const_iterator
+ it = this->Target->GetSystemIncludeDirectories().begin();
+ it != this->Target->GetSystemIncludeDirectories().end(); ++it)
{
- return true;
+ cmListFileBacktrace lfbt;
+ cmGeneratorExpression ge(lfbt);
+
+ cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+ this->GetName(),
+ "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", 0, 0);
+
+ cmSystemTools::ExpandListArgument(ge.Parse(*it)
+ ->Evaluate(this->Makefile,
+ config, false, this->Target,
+ &dagChecker), result);
}
+ IncludeCacheType::value_type entry(config_upper, result);
+ iter = this->SystemIncludesCache.insert(entry).first;
+ }
+
+ if (std::find(iter->second.begin(),
+ iter->second.end(), dir) != iter->second.end())
+ {
+ return true;
}
return false;
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index c0fd7726cd..dedfa60aa9 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -78,6 +78,8 @@ private:
void ClassifySources();
void LookupObjectLibraries();
+ std::map<std::string, std::vector<std::string> > SystemIncludesCache;
+
cmGeneratorTarget(cmGeneratorTarget const&);
void operator=(cmGeneratorTarget const&);
};
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index ad74767f74..2897114ab5 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1001,6 +1001,17 @@ void cmGlobalGenerator::Generate()
// it builds by default.
this->FillLocalGeneratorToTargetMap();
+ for (i = 0; i < this->LocalGenerators.size(); ++i)
+ {
+ cmMakefile* mf = this->LocalGenerators[i]->GetMakefile();
+ cmTargets* targets = &(mf->GetTargets());
+ for ( cmTargets::iterator it = targets->begin();
+ it != targets->end(); ++ it )
+ {
+ it->second.FinalizeSystemIncludeDirectories();
+ }
+ }
+
// Generate project files
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 7ad42f8263..806f77c346 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -843,6 +843,17 @@ void cmTarget::DefineProperties(cmake *cm)
CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
cm->DefineProperty
+ ("SYSTEM_INTERFACE_INCLUDE_DIRECTORIES", cmProperty::TARGET,
+ "List of public system include directories for a library.",
+ "Targets may populate this property to publish the include directories "
+ "which contain system headers, and therefore should not result in "
+ "compiler warnings. Consuming targets will then mark the same include "
+ "directories as system headers."
+ "\n"
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
+ CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+
+ cm->DefineProperty
("INTERFACE_COMPILE_DEFINITIONS", cmProperty::TARGET,
"List of public compile definitions for a library.",
"Targets may populate this property to publish the compile definitions "
@@ -2556,6 +2567,39 @@ cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs)
}
//----------------------------------------------------------------------------
+void cmTarget::FinalizeSystemIncludeDirectories()
+{
+ for (std::vector<cmValueWithOrigin>::const_iterator
+ it = this->Internal->LinkInterfacePropertyEntries.begin(),
+ end = this->Internal->LinkInterfacePropertyEntries.end();
+ it != end; ++it)
+ {
+ {
+ cmListFileBacktrace lfbt;
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(it->Value);
+ std::string targetName = cge->Evaluate(this->Makefile, 0,
+ false, this, 0, 0);
+ if (!this->Makefile->FindTargetToUse(targetName.c_str()))
+ {
+ continue;
+ }
+ }
+ std::string includeGenex = "$<TARGET_PROPERTY:" +
+ it->Value + ",INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>";
+ if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+ {
+ // Because it->Value is a generator expression, ensure that it
+ // evaluates to the non-empty string before being used in the
+ // TARGET_PROPERTY expression.
+ includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">";
+ }
+ this->SystemIncludeDirectories.insert(includeGenex);
+ }
+}
+
+//----------------------------------------------------------------------------
void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
{
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index ff6d9235d8..09cddaf451 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -538,6 +538,9 @@ public:
void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
std::set<cmStdString> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
+
+ void FinalizeSystemIncludeDirectories();
+
private:
// The set of include directories that are marked as system include
// directories.
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index ee915212c2..e7b906c9e8 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -84,10 +84,21 @@ void cmTargetIncludeDirectoriesCommand
const std::vector<std::string> &content,
bool prepend, bool system)
{
+ cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
+ prepend, system);
+
if (system)
{
- // Error.
+ std::string joined;
+ std::string sep;
+ for(std::vector<std::string>::const_iterator it = content.begin();
+ it != content.end(); ++it)
+ {
+ joined += sep;
+ sep = ";";
+ joined += *it;
+ }
+ tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
+ joined.c_str());
}
- cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
- prepend, system);
}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index a84ddd0cda..29686183cf 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -71,6 +71,14 @@ public:
"The following arguments specify include directories. Specified "
"include directories may be absolute paths or relative paths. "
"Repeated calls for the same <target> append items in the order called."
+ "If SYSTEM is specified, the compiler will be told the "
+ "directories are meant as system include directories on some "
+ "platforms (signalling this setting might achieve effects such as "
+ "the compiler skipping warnings, or these fixed-install system files "
+ "not being considered in dependency calculations - see compiler "
+ "docs). If SYSTEM is used together with PUBLIC or INTERFACE, the "
+ "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property will be "
+ "populated with the specified directories."
"\n"
"Arguments to target_include_directories may use \"generator "
"expressions\" with the syntax \"$<...>\". "