diff options
author | Brad King <brad.king@kitware.com> | 2019-03-22 13:15:50 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-22 13:16:02 (GMT) |
commit | 3744bd0a0afa696546afa3bd128c2c1825fd2fdb (patch) | |
tree | 6087199e98c637f4e255ef5b25662be8d6dc807e /Source | |
parent | 94be5f9344aa770d38bc5487aa57ba9566512a1e (diff) | |
parent | 413b71485a456456e204183f0d62e11e1ec3c1da (diff) | |
download | CMake-3744bd0a0afa696546afa3bd128c2c1825fd2fdb.zip CMake-3744bd0a0afa696546afa3bd128c2c1825fd2fdb.tar.gz CMake-3744bd0a0afa696546afa3bd128c2c1825fd2fdb.tar.bz2 |
Merge topic 'xcodescheme2'
413b71485a Xcode: Create Xcode schemes per target
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3098
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 53 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 7 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
3 files changed, 32 insertions, 29 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4bfa0b1..4025073 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3402,10 +3402,8 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( } this->WriteXCodePBXProj(fout, root, generators); - if (this->IsGeneratingScheme(root)) { - this->OutputXCodeSharedSchemes(xcodeDir); - } - this->OutputXCodeWorkspaceSettings(xcodeDir, root); + bool hasGeneratedSchemes = this->OutputXCodeSharedSchemes(xcodeDir, root); + this->OutputXCodeWorkspaceSettings(xcodeDir, hasGeneratedSchemes); this->ClearXCodeObjects(); @@ -3415,17 +3413,8 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( root->GetBinaryDirectory()); } -bool cmGlobalXCodeGenerator::IsGeneratingScheme(cmLocalGenerator* root) const -{ - // Since the lowest available Xcode version for testing was 6.4, - // I'm setting this as a limit then - return this->XcodeVersion >= 64 && - (root->GetMakefile()->GetCMakeInstance()->GetIsInTryCompile() || - root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_SCHEME")); -} - -void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( - const std::string& xcProjDir) +bool cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( + const std::string& xcProjDir, cmLocalGenerator* root) { // collect all tests for the targets std::map<std::string, cmXCodeScheme::TestObjects> testables; @@ -3449,21 +3438,33 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( } // generate scheme - for (auto obj : this->XCodeObjects) { - if (obj->GetType() == cmXCodeObject::OBJECT && - (obj->GetIsA() == cmXCodeObject::PBXNativeTarget || - obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) { - const std::string& targetName = obj->GetTarget()->GetName(); - cmXCodeScheme schm(obj, testables[targetName], - this->CurrentConfigurationTypes, this->XcodeVersion); - schm.WriteXCodeSharedScheme(xcProjDir, - this->RelativeToSource(xcProjDir)); + bool ret = false; + + // Since the lowest available Xcode version for testing was 6.4, + // I'm setting this as a limit then + if (this->XcodeVersion >= 64) { + for (auto obj : this->XCodeObjects) { + if (obj->GetType() == cmXCodeObject::OBJECT && + (obj->GetIsA() == cmXCodeObject::PBXNativeTarget || + obj->GetIsA() == cmXCodeObject::PBXAggregateTarget) && + (root->GetMakefile()->GetCMakeInstance()->GetIsInTryCompile() || + obj->GetTarget()->GetPropertyAsBool("XCODE_GENERATE_SCHEME"))) { + const std::string& targetName = obj->GetTarget()->GetName(); + cmXCodeScheme schm(obj, testables[targetName], + this->CurrentConfigurationTypes, + this->XcodeVersion); + schm.WriteXCodeSharedScheme(xcProjDir, + this->RelativeToSource(xcProjDir)); + ret = true; + } } } + + return ret; } void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings( - const std::string& xcProjDir, cmLocalGenerator* root) + const std::string& xcProjDir, bool hasGeneratedSchemes) { std::string xcodeSharedDataDir = xcProjDir; xcodeSharedDataDir += "/project.xcworkspace/xcshareddata"; @@ -3489,7 +3490,7 @@ void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings( xout.Element("key", "BuildSystemType"); xout.Element("string", "Original"); } - if (this->IsGeneratingScheme(root)) { + if (hasGeneratedSchemes) { xout.Element("key", "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded"); xout.Element("false"); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index b80a9ad..8daa95b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -186,11 +186,12 @@ private: std::vector<cmLocalGenerator*>& generators); void OutputXCodeProject(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); - bool IsGeneratingScheme(cmLocalGenerator* root) const; // Write shared scheme files for all the native targets - void OutputXCodeSharedSchemes(const std::string& xcProjDir); + // return true if any were written + bool OutputXCodeSharedSchemes(const std::string& xcProjDir, + cmLocalGenerator* root); void OutputXCodeWorkspaceSettings(const std::string& xcProjDir, - cmLocalGenerator* root); + bool hasGeneratedSchemes); void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 46f930a..c0b9ba1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -283,6 +283,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("FOLDER", nullptr); #ifdef __APPLE__ if (this->GetGlobalGenerator()->IsXcode()) { + this->SetPropertyDefault("XCODE_GENERATE_SCHEME", nullptr); this->SetPropertyDefault("XCODE_SCHEME_ADDRESS_SANITIZER", nullptr); this->SetPropertyDefault( "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN", nullptr); |