cmTarget: Split storage of include directories from genexes.

This commit is contained in:
Stephen Kelly 2015-08-04 20:25:02 +02:00
parent 7568199b4d
commit 1f54bc1cf3
7 changed files with 60 additions and 26 deletions

View File

@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
ti != targets.end(); ++ti)
{
cmTarget* t = &ti->second;
t->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->GeneratorTargets[t] = gt;
generatorTargets[t] = gt;

View File

@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
no_working_directory, no_depends,
noCommandLines);
tgt->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
mf->AddGeneratorTarget(tgt, gt);

View File

@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute()
AddUtilityCommand("ALL_BUILD", true, no_working_dir,
no_depends, no_commands, false,
"Build all projects");
allBuild->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt);

View File

@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends,
no_working_directory,
"echo", "Build all projects");
allbuild->Compute();
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
mf->AddGeneratorTarget(allbuild, allBuildGt);
@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
true, no_depends,
no_working_directory,
"make", "-f", file.c_str());
check->Compute();
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
mf->AddGeneratorTarget(check, checkGt);
}

View File

@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
/*byproducts=*/rcc_output, depends,
commandLines, false, autogenComment.c_str());
autogenTarget->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
makefile->AddGeneratorTarget(autogenTarget, gt);

View File

@ -168,7 +168,9 @@ public:
const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
cmLinkImplItem const& LinkImplItem;
};
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<std::string> IncludeDirectoriesEntries;
std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces;
std::vector<TargetPropertyEntry*> IncludeDirectoriesItems;
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
@ -366,13 +368,13 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const cmBacktraceRange parentIncludesBts =
this->Makefile->GetIncludeDirectoriesBacktraces();
cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin();
for (cmStringRange::const_iterator it
= parentIncludes.begin();
it != parentIncludes.end(); ++it, ++btIt)
{
this->InsertInclude(*it, *btIt);
}
this->Internal->IncludeDirectoriesEntries.insert(
this->Internal->IncludeDirectoriesEntries.end(),
parentIncludes.begin(), parentIncludes.end());
this->Internal->IncludeDirectoriesBacktraces.insert(
this->Internal->IncludeDirectoriesBacktraces.end(),
parentIncludesBts.begin(), parentIncludesBts.end());
const std::set<std::string> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories();
@ -384,7 +386,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const cmBacktraceRange parentOptionsBts =
this->Makefile->GetCompileOptionsBacktraces();
btIt = parentOptionsBts.begin();
cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin();
for (cmStringRange::const_iterator it
= parentOptions.begin();
it != parentOptions.end(); ++it, ++btIt)
@ -438,6 +440,29 @@ void cmTarget::SetMakefile(cmMakefile* mf)
}
}
void CreatePropertyGeneratorExpressions(
std::vector<std::string> const& entries,
std::vector<cmListFileBacktrace> const& backtraces,
std::vector<cmTargetInternals::TargetPropertyEntry*>& items)
{
std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin();
for (std::vector<std::string>::const_iterator it = entries.begin();
it != entries.end(); ++it, ++btIt)
{
cmGeneratorExpression ge(*btIt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
items.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
}
void cmTarget::Compute()
{
CreatePropertyGeneratorExpressions(
this->Internal->IncludeDirectoriesEntries,
this->Internal->IncludeDirectoriesBacktraces,
this->Internal->IncludeDirectoriesItems);
}
//----------------------------------------------------------------------------
void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{
@ -1666,12 +1691,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
}
else if(prop == "INCLUDE_DIRECTORIES")
{
this->Internal->IncludeDirectoriesEntries.clear();
this->Internal->IncludeDirectoriesBacktraces.clear();
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt);
deleteAndClear(this->Internal->IncludeDirectoriesEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->IncludeDirectoriesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
}
else if(prop == "COMPILE_OPTIONS")
{
@ -1764,10 +1788,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
}
else if(prop == "INCLUDE_DIRECTORIES")
{
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt);
this->Internal->IncludeDirectoriesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
}
else if(prop == "COMPILE_OPTIONS")
{
@ -1887,14 +1910,16 @@ void cmTarget::InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt,
bool before)
{
cmGeneratorExpression ge(bt);
std::vector<std::string>::iterator position =
before ? this->Internal->IncludeDirectoriesEntries.begin()
: this->Internal->IncludeDirectoriesEntries.end();
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
= before ? this->Internal->IncludeDirectoriesEntries.begin()
: this->Internal->IncludeDirectoriesEntries.end();
std::vector<cmListFileBacktrace>::iterator btPosition =
before ? this->Internal->IncludeDirectoriesBacktraces.begin()
: this->Internal->IncludeDirectoriesBacktraces.end();
this->Internal->IncludeDirectoriesEntries.insert(position,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry)));
this->Internal->IncludeDirectoriesEntries.insert(position, entry);
this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt);
}
//----------------------------------------------------------------------------
@ -2083,7 +2108,7 @@ cmTarget::GetIncludeDirectories(const std::string& config,
}
processIncludeDirectories(this,
this->Internal->IncludeDirectoriesEntries,
this->Internal->IncludeDirectoriesItems,
includes,
uniqueIncludes,
&dagChecker,
@ -2899,7 +2924,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
}
static std::string output;
MakePropertyList(output, this->Internal->IncludeDirectoriesEntries);
output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";");
return output.c_str();
}
else if(prop == propCOMPILE_FEATURES)
@ -4805,7 +4830,7 @@ cmTargetInternalPointer
//----------------------------------------------------------------------------
cmTargetInternalPointer::~cmTargetInternalPointer()
{
cmDeleteAll(this->Pointer->IncludeDirectoriesEntries);
cmDeleteAll(this->Pointer->IncludeDirectoriesItems);
cmDeleteAll(this->Pointer->CompileOptionsEntries);
cmDeleteAll(this->Pointer->CompileFeaturesEntries);
cmDeleteAll(this->Pointer->CompileDefinitionsEntries);

View File

@ -132,6 +132,8 @@ public:
void AddPostBuildCommand(cmCustomCommand const &cmd)
{this->PostBuildCommands.push_back(cmd);}
void Compute();
/**
* Get the list of the source files used by this target
*/