diff options
author | Brad King <brad.king@kitware.com> | 2015-01-19 18:57:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-01-19 18:57:29 (GMT) |
commit | 5806f6c5e61fa1707ba1903a368e0e226477e4e4 (patch) | |
tree | 448d536922d65a08aafcf21c9167a08678b6d32a /Source | |
parent | 55e78dbee376961ee05e89e23a69ce6a970bdcbc (diff) | |
parent | 9e0176e2b37b93f34718b6333edd73302b5c5350 (diff) | |
download | CMake-5806f6c5e61fa1707ba1903a368e0e226477e4e4.zip CMake-5806f6c5e61fa1707ba1903a368e0e226477e4e4.tar.gz CMake-5806f6c5e61fa1707ba1903a368e0e226477e4e4.tar.bz2 |
Merge branch 'xcode-target-sort' into release
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 62 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 6 |
2 files changed, 54 insertions, 14 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 13e6988..637e60d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -966,16 +966,40 @@ struct cmSourceFilePathCompare }; //---------------------------------------------------------------------------- -void +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, std::vector<cmXCodeObject*>& targets) { this->SetCurrentLocalGenerator(gen); cmTargets &tgts = this->CurrentMakefile->GetTargets(); + typedef std::map<std::string, cmTarget*, cmCompareTargets> 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 @@ -992,7 +1016,12 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, if(cmtarget.GetType() == cmTarget::UTILITY || cmtarget.GetType() == cmTarget::GLOBAL_TARGET) { - targets.push_back(this->CreateUtilityTarget(cmtarget)); + cmXCodeObject* t = this->CreateUtilityTarget(cmtarget); + if (!t) + { + return false; + } + targets.push_back(t); continue; } @@ -1000,7 +1029,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmSourceFile*> classes; if (!cmtarget.GetConfigCommonSourceFiles(classes)) { - return; + return false; } std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); @@ -1227,6 +1256,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, targets.push_back(this->CreateXCodeTarget(cmtarget, buildPhases)); } + return true; } //---------------------------------------------------------------------------- @@ -2940,7 +2970,7 @@ void cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, +bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) { @@ -2983,7 +3013,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, std::vector<cmSourceFile*> classes; if (!cmtarget.GetConfigCommonSourceFiles(classes)) { - return; + return false; } // Put cmSourceFile instances in proper groups: for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); @@ -3016,6 +3046,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } } } + return true; } cmXCodeObject *cmGlobalXCodeGenerator @@ -3136,7 +3167,7 @@ cmXCodeObject* cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator +bool cmGlobalXCodeGenerator ::CreateXCodeObjects(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) @@ -3217,7 +3248,10 @@ void cmGlobalXCodeGenerator this->MainGroupChildren->AddObject(resourcesGroup); // now create the cmake groups - this->CreateGroups(root, generators); + if (!this->CreateGroups(root, generators)) + { + return false; + } cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); productGroup->AddAttribute("name", this->CreateString("Products")); @@ -3417,7 +3451,10 @@ void cmGlobalXCodeGenerator { if(!this->IsExcluded(root, *i)) { - this->CreateXCodeTargets(*i, targets); + if (!this->CreateXCodeTargets(*i, targets)) + { + return false; + } } } // loop over all targets and add link and depend info @@ -3446,6 +3483,7 @@ void cmGlobalXCodeGenerator } } this->RootObject->AddAttribute("targets", allTargets); + return true; } //---------------------------------------------------------------------------- @@ -3632,8 +3670,10 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, } } - this->CreateXCodeObjects(root, - generators); + if (!this->CreateXCodeObjects(root, generators)) + { + return; + } std::string xcodeDir = root->GetMakefile()->GetStartOutputDirectory(); xcodeDir += "/"; xcodeDir += root->GetMakefile()->GetProjectName(); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 9d7b784..8d7cfaf 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -91,7 +91,7 @@ private: cmSourceGroup* sg); cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent, std::string name); - void CreateGroups(cmLocalGenerator* root, + bool CreateGroups(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); std::string XCodeEscapePath(const char* p); @@ -151,7 +151,7 @@ private: std::string ExtractFlag(const char* flag, std::string& flags); // delete all objects in the this->XCodeObjects vector. void ClearXCodeObjects(); - void CreateXCodeObjects(cmLocalGenerator* root, + bool CreateXCodeObjects(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); void OutputXCodeProject(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); @@ -170,7 +170,7 @@ private: cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen, cmSourceFile* sf, cmTarget& cmtarget); - void CreateXCodeTargets(cmLocalGenerator* gen, + bool CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*>&); bool IsHeaderFile(cmSourceFile*); void AddDependTarget(cmXCodeObject* target, |