diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 09d5c79bc..637e60d19 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -965,6 +965,23 @@ struct cmSourceFilePathCompare } }; +//---------------------------------------------------------------------------- +struct cmCompareTargets +{ + bool operator () (std::string const& a, std::string const& b) const + { + if (a == "ALL_BUILD") + { + return true; + } + if (b == "ALL_BUILD") + { + return false; + } + return strcmp(a.c_str(), b.c_str()) < 0; + } +}; + //---------------------------------------------------------------------------- bool cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, @@ -973,9 +990,16 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, { this->SetCurrentLocalGenerator(gen); cmTargets &tgts = this->CurrentMakefile->GetTargets(); + typedef std::map cmSortedTargets; + cmSortedTargets sortedTargets; for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - cmTarget& cmtarget = l->second; + sortedTargets[l->first] = &l->second; + } + for(cmSortedTargets::iterator l = sortedTargets.begin(); + l != sortedTargets.end(); l++) + { + cmTarget& cmtarget = *l->second; cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); // make sure ALL_BUILD, INSTALL, etc are only done once