From fb45559e0924467523bd372a3c037861d8b11c51 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jul 2018 12:47:45 -0400 Subject: [PATCH] Xcode: Process targets in depth-first order during generation The Xcode 10 "new build system" requires more strict handling of custom commands. It may need a fix similar to what commit v3.12.0-rc1~171^2 (VS: Generate a custom command only in the least dependent target, 2018-03-23) did for VS. Prepare for this by generating targets within each local generator in dependency order. Issue: #18070 --- Source/cmGlobalXCodeGenerator.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index df4e50767d..042ce41e8c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1083,8 +1083,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( cmLocalGenerator* gen, std::vector& targets) { this->SetCurrentLocalGenerator(gen); - std::vector const& gts = + std::vector gts = this->CurrentLocalGenerator->GetGeneratorTargets(); + std::sort(gts.begin(), gts.end(), + [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) { + return this->TargetOrderIndex[l] < this->TargetOrderIndex[r]; + }); for (auto gtgt : gts) { if (!this->CreateXCodeTarget(gtgt, targets)) { return false;