Fix support for OLD behavior of policy CMP0002

The commit "Cleanup make progress rule generation code" introduced a map
from target name to the progress.make file location.  Policy CMP0002's
OLD behavior allows duplicate target names in different directories, so
only one ends up with a progress.make file.  This commit fixes the map
to order by target name first and build directory second, restoring
support for duplicate target names.
This commit is contained in:
Brad King 2009-09-28 17:34:23 -04:00
parent a091e99cb9
commit 0089f9cf8f
2 changed files with 21 additions and 4 deletions

View File

@ -750,7 +750,7 @@ cmGlobalUnixMakefileGenerator3
cmLocalGenerator::FULL, cmLocalGenerator::FULL,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
progCmd << " "; progCmd << " ";
std::vector<int> &progFiles = this->ProgressMap[t->first].Marks; std::vector<int> &progFiles = this->ProgressMap[&t->second].Marks;
for (std::vector<int>::iterator i = progFiles.begin(); for (std::vector<int>::iterator i = progFiles.begin();
i != progFiles.end(); ++i) i != progFiles.end(); ++i)
{ {
@ -873,7 +873,7 @@ cmGlobalUnixMakefileGenerator3
size_t count = 0; size_t count = 0;
if(emitted.insert(target).second) if(emitted.insert(target).second)
{ {
count = this->ProgressMap[target->GetName()].Marks.size(); count = this->ProgressMap[target].Marks.size();
TargetDependSet const& depends = this->GetTargetDirectDepends(*target); TargetDependSet const& depends = this->GetTargetDirectDepends(*target);
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
@ -905,11 +905,26 @@ void
cmGlobalUnixMakefileGenerator3::RecordTargetProgress( cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
cmMakefileTargetGenerator* tg) cmMakefileTargetGenerator* tg)
{ {
TargetProgress& tp = this->ProgressMap[tg->GetTarget()->GetName()]; TargetProgress& tp = this->ProgressMap[tg->GetTarget()];
tp.NumberOfActions = tg->GetNumberOfProgressActions(); tp.NumberOfActions = tg->GetNumberOfProgressActions();
tp.VariableFile = tg->GetProgressFileNameFull(); tp.VariableFile = tg->GetProgressFileNameFull();
} }
//----------------------------------------------------------------------------
bool
cmGlobalUnixMakefileGenerator3::ProgressMapCompare
::operator()(cmTarget* l, cmTarget* r)
{
// Order by target name.
if(int c = strcmp(l->GetName(), r->GetName()))
{
return c < 0;
}
// Order duplicate targets by binary directory.
return strcmp(l->GetMakefile()->GetCurrentOutputDirectory(),
r->GetMakefile()->GetCurrentOutputDirectory()) < 0;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGlobalUnixMakefileGenerator3::TargetProgress cmGlobalUnixMakefileGenerator3::TargetProgress

View File

@ -180,7 +180,9 @@ protected:
std::vector<int> Marks; std::vector<int> Marks;
void WriteProgressVariables(unsigned long total, unsigned long& current); void WriteProgressVariables(unsigned long total, unsigned long& current);
}; };
typedef std::map<cmStdString, TargetProgress> ProgressMapType; struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*); };
typedef std::map<cmTarget*, TargetProgress,
ProgressMapCompare> ProgressMapType;
ProgressMapType ProgressMap; ProgressMapType ProgressMap;
size_t CountProgressMarksInTarget(cmTarget* target, size_t CountProgressMarksInTarget(cmTarget* target,