Move GetIncludeDirectories to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2012-09-16 10:03:42 +02:00
parent f9146f6b90
commit 290e92ada8
16 changed files with 68 additions and 52 deletions

View File

@ -636,9 +636,11 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
// the include directories for this target // the include directories for this target
std::set<std::string> uniqIncludeDirs; std::set<std::string> uniqIncludeDirs;
cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target);
std::vector<std::string> includes; std::vector<std::string> includes;
target->GetMakefile()->GetLocalGenerator()-> target->GetMakefile()->GetLocalGenerator()->
GetIncludeDirectories(includes, target); GetIncludeDirectories(includes, gtgt);
for(std::vector<std::string>::const_iterator dirIt=includes.begin(); for(std::vector<std::string>::const_iterator dirIt=includes.begin();
dirIt != includes.end(); dirIt != includes.end();
++dirIt) ++dirIt)

View File

@ -884,11 +884,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
it != this->GlobalGenerator->GetLocalGenerators().end(); it != this->GlobalGenerator->GetLocalGenerators().end();
++it) ++it)
{ {
cmTargets & targets = (*it)->GetMakefile()->GetTargets(); cmGeneratorTargetsType targets = (*it)->GetMakefile()
for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) ->GetGeneratorTargets();
for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l)
{ {
std::vector<std::string> includeDirs; std::vector<std::string> includeDirs;
(*it)->GetIncludeDirectories(includeDirs, &l->second); (*it)->GetIncludeDirectories(includeDirs, l->second);
this->AppendIncludeDirectories(fout, includeDirs, emmited); this->AppendIncludeDirectories(fout, includeDirs, emmited);
} }
} }

View File

@ -355,3 +355,27 @@ const char* cmGeneratorTarget::GetCreateRuleVariable()
} }
return ""; return "";
} }
//----------------------------------------------------------------------------
std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories()
{
std::vector<std::string> includes;
const char *prop = this->Target->GetProperty("INCLUDE_DIRECTORIES");
if(prop)
{
cmSystemTools::ExpandListArgument(prop, includes);
}
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
for(std::vector<std::string>::const_iterator
li = includes.begin(); li != includes.end(); ++li)
{
if(uniqueIncludes.insert(*li).second)
{
orderedAndUniqueIncludes.push_back(*li);
}
}
return orderedAndUniqueIncludes;
}

View File

@ -74,6 +74,9 @@ public:
// need to add CMAKE_(LANG) for full name. // need to add CMAKE_(LANG) for full name.
const char* GetCreateRuleVariable(); const char* GetCreateRuleVariable();
/** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories();
private: private:
void ClassifySources(); void ClassifySources();
void LookupObjectLibraries(); void LookupObjectLibraries();

View File

@ -1133,13 +1133,13 @@ void cmGlobalGenerator::CheckLocalGenerators()
{ {
manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager(); manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
this->LocalGenerators[i]->ConfigureFinalPass(); this->LocalGenerators[i]->ConfigureFinalPass();
cmTargets & targets = cmGeneratorTargetsType targets =
this->LocalGenerators[i]->GetMakefile()->GetTargets(); this->LocalGenerators[i]->GetMakefile()->GetGeneratorTargets();
for (cmTargets::iterator l = targets.begin(); for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); l++) l != targets.end(); l++)
{ {
const cmTarget::LinkLibraryVectorType& libs = const cmTarget::LinkLibraryVectorType& libs =
l->second.GetOriginalLinkLibraries(); l->second->Target->GetOriginalLinkLibraries();
for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin(); for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
lib != libs.end(); ++lib) lib != libs.end(); ++lib)
{ {
@ -1155,14 +1155,14 @@ void cmGlobalGenerator::CheckLocalGenerators()
} }
std::string text = notFoundMap[varName]; std::string text = notFoundMap[varName];
text += "\n linked by target \""; text += "\n linked by target \"";
text += l->second.GetName(); text += l->second->GetName();
text += "\" in directory "; text += "\" in directory ";
text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory(); text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
notFoundMap[varName] = text; notFoundMap[varName] = text;
} }
} }
std::vector<std::string> incs; std::vector<std::string> incs;
this->LocalGenerators[i]->GetIncludeDirectories(incs, &l->second); this->LocalGenerators[i]->GetIncludeDirectories(incs, l->second);
for( std::vector<std::string>::const_iterator incDir = incs.begin(); for( std::vector<std::string>::const_iterator incDir = incs.begin();
incDir != incs.end(); ++incDir) incDir != incs.end(); ++incDir)

View File

@ -1953,7 +1953,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
std::vector<std::string> includes; std::vector<std::string> includes;
this->CurrentLocalGenerator->GetIncludeDirectories(includes, &target); cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt);
std::set<cmStdString> emitted; std::set<cmStdString> emitted;
emitted.insert("/System/Library/Frameworks"); emitted.insert("/System/Library/Frameworks");
for(std::vector<std::string>::iterator i = includes.begin(); for(std::vector<std::string>::iterator i = includes.begin();

View File

@ -577,7 +577,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
flags += " "; flags += " ";
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->GetIncludeDirectories(includes, target.Target, lang); this->GetIncludeDirectories(includes, &target, lang);
flags += this->GetIncludeFlags(includes, lang); flags += this->GetIncludeFlags(includes, lang);
} }
flags += this->Makefile->GetDefineFlags(); flags += this->Makefile->GetDefineFlags();
@ -1320,7 +1320,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmTarget* target, cmGeneratorTarget* target,
const char* lang) const char* lang)
{ {
// Need to decide whether to automatically include the source and // Need to decide whether to automatically include the source and

View File

@ -206,7 +206,7 @@ public:
/** Get the include flags for the current makefile and language. */ /** Get the include flags for the current makefile and language. */
void GetIncludeDirectories(std::vector<std::string>& dirs, void GetIncludeDirectories(std::vector<std::string>& dirs,
cmTarget* target, cmGeneratorTarget* target,
const char* lang = "C"); const char* lang = "C");
/** Compute the language used to compile the given source file. */ /** Compute the language used to compile the given source file. */

View File

@ -862,10 +862,13 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target)
// the length threatens this problem. // the length threatens this problem.
unsigned int maxIncludeLength = 3000; unsigned int maxIncludeLength = 3000;
bool useShortPath = false; bool useShortPath = false;
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
for(int j=0; j < 2; ++j) for(int j=0; j < 2; ++j)
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target); this->GetIncludeDirectories(includes, gt);
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i) for(i = includes.begin(); i != includes.end(); ++i)

View File

@ -819,7 +819,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
fout << "\t\t\t\tAdditionalIncludeDirectories=\""; fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
std::vector<std::string> includes; std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
this->GetIncludeDirectories(includes, gt);
std::vector<std::string>::iterator i = includes.begin(); std::vector<std::string>::iterator i = includes.begin();
for(;i != includes.end(); ++i) for(;i != includes.end(); ++i)
{ {

View File

@ -58,11 +58,12 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
// Now extract any include paths from the targets // Now extract any include paths from the targets
std::set<std::string> uniqueIncludes; std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes; std::vector<std::string> orderedAndUniqueIncludes;
cmTargets & targets = this->Makefile->GetTargets(); cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l)
{ {
const std::vector<std::string>& includes = const std::vector<std::string>& includes =
l->second.GetIncludeDirectories(); l->second->GetIncludeDirectories();
for(std::vector<std::string>::const_iterator j = includes.begin(); for(std::vector<std::string>::const_iterator j = includes.begin();
j != includes.end(); ++j) j != includes.end(); ++j)
{ {

View File

@ -1062,7 +1062,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
*this->InfoFileStream *this->InfoFileStream
<< "SET(CMAKE_C_TARGET_INCLUDE_PATH\n"; << "SET(CMAKE_C_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
for(std::vector<std::string>::iterator i = includes.begin(); for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) i != includes.end(); ++i)
{ {
@ -1547,7 +1548,8 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags()
emitted.insert("/System/Library/Frameworks"); emitted.insert("/System/Library/Frameworks");
#endif #endif
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
// check all include directories for frameworks as this // check all include directories for frameworks as this
// will already have added a -F for the framework // will already have added a -F for the framework
@ -1852,7 +1854,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target, lang); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget, lang);
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile); this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile);
@ -1955,7 +1958,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
for(std::vector<std::string>::const_iterator idi = includes.begin(); for(std::vector<std::string>::const_iterator idi = includes.begin();
idi != includes.end(); ++idi) idi != includes.end(); ++idi)
{ {

View File

@ -152,7 +152,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
// Add include directory flags. // Add include directory flags.
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target, this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
language.c_str()); language.c_str());
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), this->LocalGenerator->GetIncludeFlags(includes, language.c_str(),

View File

@ -4559,30 +4559,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item)
return lib; return lib;
} }
//----------------------------------------------------------------------------
std::vector<std::string> cmTarget::GetIncludeDirectories()
{
std::vector<std::string> includes;
const char *prop = this->GetProperty("INCLUDE_DIRECTORIES");
if(prop)
{
cmSystemTools::ExpandListArgument(prop, includes);
}
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
for(std::vector<std::string>::const_iterator
li = includes.begin(); li != includes.end(); ++li)
{
if(uniqueIncludes.insert(*li).second)
{
orderedAndUniqueIncludes.push_back(*li);
}
}
return orderedAndUniqueIncludes;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmTarget::GetFrameworkDirectory(const char* config) std::string cmTarget::GetFrameworkDirectory(const char* config)
{ {

View File

@ -437,9 +437,6 @@ public:
directory. */ directory. */
bool UsesDefaultOutputDir(const char* config, bool implib); bool UsesDefaultOutputDir(const char* config, bool implib);
/** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories();
/** Append to @a base the mac content directory and return it. */ /** Append to @a base the mac content directory and return it. */
std::string BuildMacContentDirectory(const std::string& base, std::string BuildMacContentDirectory(const std::string& base,
const char* config = 0, const char* config = 0,

View File

@ -1594,7 +1594,8 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations(); (this->GlobalGenerator)->GetConfigurations();
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->Target); this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget);
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i) i != configs->end(); ++i)
{ {