cmTarget: Extract a ProcessSourceItemCMP0049 method.

Avoid calling AddSource for each src filename.  That involves
checking each entry for uniqueness and creating a separate
generator expression for each one.

Instead, add a single entry for the list of sources.  The source
files are passed through a uniqueness filter at generate-time, so
duplicates don't matter so much.
This commit is contained in:
Stephen Kelly 2014-04-04 17:45:28 +02:00
parent 19b7c22d02
commit eb163f37d4
2 changed files with 41 additions and 9 deletions

View File

@ -812,23 +812,41 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
//----------------------------------------------------------------------------
void cmTarget::AddSources(std::vector<std::string> const& srcs)
{
std::string srcFiles;
const char* sep = "";
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
{
const char* src = i->c_str();
if(src[0] == '$' && src[1] == '<')
std::string filename = *i;
const char* src = filename.c_str();
if(!(src[0] == '$' && src[1] == '<'))
{
this->AddSource(src);
}
else
{
this->AddSourceCMP0049(src);
filename = this->ProcessSourceItemCMP0049(filename);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
this->Makefile->GetOrCreateSource(filename);
}
srcFiles += sep;
srcFiles += filename;
sep = ";";
}
if (!srcFiles.empty())
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
cge->SetEvaluateForBuildsystem(true);
this->Internal->SourceEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
}
}
//----------------------------------------------------------------------------
cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
{
std::string src = s;
@ -863,10 +881,22 @@ cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
return 0;
return "";
}
}
}
return src;
}
//----------------------------------------------------------------------------
cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
{
std::string src = this->ProcessSourceItemCMP0049(s);
if (cmSystemTools::GetErrorOccuredFlag())
{
return 0;
}
return this->AddSource(src);
}

View File

@ -752,6 +752,8 @@ private:
void ComputeLinkClosure(const std::string& config, LinkClosure& lc,
cmTarget const* head) const;
std::string ProcessSourceItemCMP0049(const std::string& s);
void ClearLinkMaps();
void MaybeInvalidatePropertyCache(const std::string& prop);