From 1714c27a74c1616e5998a1a51fe42848a1f1c389 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 25 Jan 2013 09:26:35 +0100 Subject: Process generator expressions for 'system' include directories. Since commit 08cb4fa4 (Process generator expressions in the INCLUDE_DIRECTORIES property., 2012-09-18), it is possible to use generator expressions with the include_directories command. As that command can also have a SYSTEM argument, ensure that the result of using that argument with generator expressions gives a sane result. --- Source/cmLocalGenerator.cxx | 5 +++-- Source/cmLocalGenerator.h | 3 ++- Source/cmMakefile.cxx | 21 ++++++++++++++++++--- Source/cmMakefile.h | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ecf6b41..dc39fdc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1212,7 +1212,8 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path) //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetIncludeFlags( const std::vector &includes, - const char* lang, bool forResponseFile) + const char* lang, bool forResponseFile, + const char *config) { if(!lang) { @@ -1285,7 +1286,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if(!flagUsed || repeatFlag) { if(sysIncludeFlag && - this->Makefile->IsSystemIncludeDirectory(i->c_str())) + this->Makefile->IsSystemIncludeDirectory(i->c_str(), config)) { includeFlags << sysIncludeFlag; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index b2ff0c4..84cf6ca 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -149,7 +149,8 @@ public: virtual void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language std::string GetIncludeFlags(const std::vector &includes, - const char* lang, bool forResponseFile = false); + const char* lang, bool forResponseFile = false, + const char *config = 0); /** * Encode a list of preprocessor definitions for the compiler diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e7a1500..58e3f8e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -23,6 +23,7 @@ #include "cmListFileCache.h" #include "cmCommandArgumentParserHelper.h" #include "cmDocumentCompileDefinitions.h" +#include "cmGeneratorExpression.h" #include "cmTest.h" #ifdef CMAKE_BUILD_WITH_CMAKE # include "cmVariableWatch.h" @@ -1665,10 +1666,24 @@ cmMakefile::AddSystemIncludeDirectories(const std::set &incs) } //---------------------------------------------------------------------------- -bool cmMakefile::IsSystemIncludeDirectory(const char* dir) +bool cmMakefile::IsSystemIncludeDirectory(const char* dir, const char *config) { - return (this->SystemIncludeDirectories.find(dir) != - this->SystemIncludeDirectories.end()); + for (std::set::const_iterator + it = this->SystemIncludeDirectories.begin(); + it != this->SystemIncludeDirectories.end(); ++it) + { + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + std::vector 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) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a2783f2..c0020bf 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -547,7 +547,7 @@ public: * Mark include directories as system directories. */ void AddSystemIncludeDirectories(const std::set &incs); - bool IsSystemIncludeDirectory(const char* dir); + bool IsSystemIncludeDirectory(const char* dir, const char *config); /** Expand out any arguements in the vector that have ; separated * strings into multiple arguements. A new vector is created -- cgit v0.12