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.
This commit is contained in:
Stephen Kelly 2013-01-25 09:26:35 +01:00
parent 2ce7231f56
commit 1714c27a74
4 changed files with 24 additions and 7 deletions

View File

@ -1212,7 +1212,8 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
//----------------------------------------------------------------------------
std::string cmLocalGenerator::GetIncludeFlags(
const std::vector<std::string> &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;
}

View File

@ -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<std::string> &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

View File

@ -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<cmStdString> &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<cmStdString>::const_iterator
it = this->SystemIncludeDirectories.begin();
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)

View File

@ -547,7 +547,7 @@ public:
* Mark include directories as system directories.
*/
void AddSystemIncludeDirectories(const std::set<cmStdString> &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