Commit 59ade844 authored by Brad King's avatar Brad King
Browse files

Ninja: Fix non-determinism in generated build statement order (#15968)

Generate custom command build statements in the order we encounter
source files specifying them.  Do not depend on pointer values of
internally allocated structures for ordering.
parent a5a5a685
......@@ -454,13 +454,24 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
cmGeneratorTarget* target)
CustomCommandTargetMap::value_type v(cc, std::set<cmGeneratorTarget*>());
std::pair<CustomCommandTargetMap::iterator, bool>
ins = this->CustomCommandTargets.insert(v);
if (ins.second)
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
for (CustomCommandTargetMap::iterator i = this->CustomCommandTargets.begin();
i != this->CustomCommandTargets.end(); ++i) {
for (std::vector<cmCustomCommand const*>::iterator vi =
this->CustomCommands.begin(); vi != this->CustomCommands.end(); ++vi)
CustomCommandTargetMap::iterator i = this->CustomCommandTargets.find(*vi);
assert(i != this->CustomCommandTargets.end());
// A custom command may appear on multiple targets. However, some build
// systems exist where the target dependencies on some of the targets are
// overspecified, leading to a dependency cycle. If we assume all target
......@@ -106,6 +106,7 @@ private:
typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*> >
CustomCommandTargetMap CustomCommandTargets;
std::vector<cmCustomCommand const*> CustomCommands;
#endif // ! cmLocalNinjaGenerator_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment