Add Target API to determine if an include is a system include.

The implementation can be modified later so that system includes
can be determined on a per-target basis.
This commit is contained in:
Stephen Kelly 2013-07-01 22:28:26 +02:00
parent 2679a34a94
commit f1fcbe3fde
8 changed files with 20 additions and 7 deletions

View File

@ -421,7 +421,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
std::vector<std::string> includes; std::vector<std::string> includes;
lg->GetIncludeDirectories(includes, gtgt, language, config); lg->GetIncludeDirectories(includes, gtgt, language, config);
std::string includeFlags = std::string includeFlags =
lg->GetIncludeFlags(includes, language, true); // full include paths lg->GetIncludeFlags(includes, gtgt, language, true); // full include paths
lg->AppendFlags(flags, includeFlags.c_str()); lg->AppendFlags(flags, includeFlags.c_str());
} }

View File

@ -47,6 +47,13 @@ const char *cmGeneratorTarget::GetProperty(const char *prop)
return this->Target->GetProperty(prop); return this->Target->GetProperty(prop);
} }
//----------------------------------------------------------------------------
bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
const char *config)
{
return this->Makefile->IsSystemIncludeDirectory(dir, config);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) bool cmGeneratorTarget::GetPropertyAsBool(const char *prop)
{ {

View File

@ -72,6 +72,8 @@ public:
/** Get the include directories for this target. */ /** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories(const char *config); std::vector<std::string> GetIncludeDirectories(const char *config);
bool IsSystemIncludeDirectory(const char *dir, const char *config);
private: private:
void ClassifySources(); void ClassifySources();
void LookupObjectLibraries(); void LookupObjectLibraries();

View File

@ -577,7 +577,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target, lang); this->GetIncludeDirectories(includes, &target, lang);
flags += this->GetIncludeFlags(includes, lang); flags += this->GetIncludeFlags(includes, &target, lang);
} }
flags += this->Makefile->GetDefineFlags(); flags += this->Makefile->GetDefineFlags();
@ -1224,6 +1224,7 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmLocalGenerator::GetIncludeFlags( std::string cmLocalGenerator::GetIncludeFlags(
const std::vector<std::string> &includes, const std::vector<std::string> &includes,
cmGeneratorTarget* target,
const char* lang, bool forResponseFile, const char* lang, bool forResponseFile,
const char *config) const char *config)
{ {
@ -1296,8 +1297,8 @@ std::string cmLocalGenerator::GetIncludeFlags(
if(!flagUsed || repeatFlag) if(!flagUsed || repeatFlag)
{ {
if(sysIncludeFlag && if(sysIncludeFlag && target &&
this->Makefile->IsSystemIncludeDirectory(i->c_str(), config)) target->IsSystemIncludeDirectory(i->c_str(), config))
{ {
includeFlags << sysIncludeFlag; includeFlags << sysIncludeFlag;
} }

View File

@ -152,6 +152,7 @@ public:
virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); virtual void AppendFlagEscape(std::string& flags, const char* rawFlag);
///! Get the include flags for the current makefile and language ///! Get the include flags for the current makefile and language
std::string GetIncludeFlags(const std::vector<std::string> &includes, std::string GetIncludeFlags(const std::vector<std::string> &includes,
cmGeneratorTarget* target,
const char* lang, bool forResponseFile = false, const char* lang, bool forResponseFile = false,
const char *config = 0); const char *config = 0);

View File

@ -1853,7 +1853,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
lang, config); lang, config);
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile); this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
lang, useResponseFile);
if(includeFlags.empty()) if(includeFlags.empty())
{ {
return; return;

View File

@ -161,7 +161,8 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
this->GeneratorTarget, this->GeneratorTarget,
language.c_str(), config); language.c_str(), config);
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
language.c_str(),
language == "RC" ? true : false); // full include paths for RC language == "RC" ? true : false); // full include paths for RC
// needed by cmcldeps // needed by cmcldeps
if(cmGlobalNinjaGenerator::IsMinGW()) if(cmGlobalNinjaGenerator::IsMinGW())

View File

@ -612,7 +612,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::vector<std::string> includeDirs; std::vector<std::string> includeDirs;
cmSystemTools::ExpandListArgument(includes, includeDirs); cmSystemTools::ExpandListArgument(includes, includeDirs);
std::string includeFlags = lg->GetIncludeFlags(includeDirs, std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0,
language.c_str(), false); language.c_str(), false);
std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");