summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-10 19:08:48 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-11 13:53:37 (GMT)
commit59ade844ef01f0c8a4db3a5593f79210edcf6cbc (patch)
treec3512a64d5d056f5f51ffeac253e9528d92a5ace /Source/cmLocalNinjaGenerator.cxx
parenta5a5a6857241c21d306661d723b749839f4c6e1a (diff)
downloadCMake-59ade844ef01f0c8a4db3a5593f79210edcf6cbc.zip
CMake-59ade844ef01f0c8a4db3a5593f79210edcf6cbc.tar.gz
CMake-59ade844ef01f0c8a4db3a5593f79210edcf6cbc.tar.bz2
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.
Diffstat (limited to 'Source/cmLocalNinjaGenerator.cxx')
-rw-r--r--Source/cmLocalNinjaGenerator.cxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index b2927a9..8a68af6 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -454,13 +454,24 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
cmGeneratorTarget* target)
{
- this->CustomCommandTargets[cc].insert(target);
+ CustomCommandTargetMap::value_type v(cc, std::set<cmGeneratorTarget*>());
+ std::pair<CustomCommandTargetMap::iterator, bool>
+ ins = this->CustomCommandTargets.insert(v);
+ if (ins.second)
+ {
+ this->CustomCommands.push_back(cc);
+ }
+ ins.first->second.insert(target);
}
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