From 0bad9eba46f6899a4c59431e7136a868d0003854 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jul 2018 11:54:10 -0400 Subject: Xcode: Refactor storage of ordered list of targets Sort the resulting Xcode object list so that the actual order of generation does not matter. --- Source/cmGlobalXCodeGenerator.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7d07860..df4e507 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1065,15 +1065,17 @@ struct cmSourceFilePathCompare struct cmCompareTargets { - bool operator()(std::string const& a, std::string const& b) const + bool operator()(cmXCodeObject* l, cmXCodeObject* r) const { + std::string const& a = l->GetTarget()->GetName(); + std::string const& b = r->GetTarget()->GetName(); if (a == "ALL_BUILD") { return true; } if (b == "ALL_BUILD") { return false; } - return strcmp(a.c_str(), b.c_str()) < 0; + return a < b; } }; @@ -1081,18 +1083,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( cmLocalGenerator* gen, std::vector& targets) { this->SetCurrentLocalGenerator(gen); - typedef std::map - cmSortedTargets; - cmSortedTargets sortedTargets; - for (auto tgt : this->CurrentLocalGenerator->GetGeneratorTargets()) { - sortedTargets[tgt->GetName()] = tgt; - } - for (auto& sortedTarget : sortedTargets) { - cmGeneratorTarget* gtgt = sortedTarget.second; + std::vector const& gts = + this->CurrentLocalGenerator->GetGeneratorTargets(); + for (auto gtgt : gts) { if (!this->CreateXCodeTarget(gtgt, targets)) { return false; } } + std::sort(targets.begin(), targets.end(), cmCompareTargets()); return true; } -- cgit v0.12