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
std::set<std::string> uniqIncludeDirs;
cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target);
std::vector<std::string> includes;
target->GetMakefile()->GetLocalGenerator()->
GetIncludeDirectories(includes, target);
GetIncludeDirectories(includes, gtgt);
for(std::vector<std::string>::const_iterator dirIt=includes.begin();
dirIt != includes.end();
++dirIt)

View File

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

View File

@ -355,3 +355,27 @@ const char* cmGeneratorTarget::GetCreateRuleVariable()
}
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.
const char* GetCreateRuleVariable();
/** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories();
private:
void ClassifySources();
void LookupObjectLibraries();

View File

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

View File

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

View File

@ -577,7 +577,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
flags += " ";
{
std::vector<std::string> includes;
this->GetIncludeDirectories(includes, target.Target, lang);
this->GetIncludeDirectories(includes, &target, lang);
flags += this->GetIncludeFlags(includes, lang);
}
flags += this->Makefile->GetDefineFlags();
@ -1320,7 +1320,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
//----------------------------------------------------------------------------
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmTarget* target,
cmGeneratorTarget* target,
const char* lang)
{
// 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. */
void GetIncludeDirectories(std::vector<std::string>& dirs,
cmTarget* target,
cmGeneratorTarget* target,
const char* lang = "C");
/** 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.
unsigned int maxIncludeLength = 3000;
bool useShortPath = false;
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
for(int j=0; j < 2; ++j)
{
std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target);
this->GetIncludeDirectories(includes, gt);
std::vector<std::string>::iterator 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");
fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
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();
for(;i != includes.end(); ++i)
{

View File

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

View File

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

View File

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

View File

@ -4559,30 +4559,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item)
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)
{

View File

@ -437,9 +437,6 @@ public:
directory. */
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. */
std::string BuildMacContentDirectory(const std::string& base,
const char* config = 0,

View File

@ -1594,7 +1594,8 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
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();
i != configs->end(); ++i)
{