Ninja: Fix non-determinism in generated target dependency order (#15968)

We represent target dependency sets as `set<cmTargetDepend>` which
orders by a `cmGeneratorTarget const*` pointer value.  Therefore the
order of dependencies encountered in AppendTargetDepends is not
predictable.  Sort them by content to make the result deterministic.
This commit is contained in:
Brad King 2016-02-12 08:45:09 -05:00
parent 59ade844ef
commit 46fa958362
1 changed files with 4 additions and 1 deletions

View File

@ -991,6 +991,7 @@ cmGlobalNinjaGenerator
std::set<std::string> const& utils = target->GetUtilities();
std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
} else {
cmNinjaDeps outs;
cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
for (cmTargetDependSet::const_iterator i = targetDeps.begin();
i != targetDeps.end(); ++i)
@ -999,8 +1000,10 @@ cmGlobalNinjaGenerator
{
continue;
}
this->AppendTargetOutputs(*i, outputs);
this->AppendTargetOutputs(*i, outs);
}
std::sort(outs.begin(), outs.end());
outputs.insert(outputs.end(), outs.begin(), outs.end());
}
}