diff options
author | Brad King <brad.king@kitware.com> | 2019-04-12 11:23:24 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-04-12 11:23:31 (GMT) |
commit | 680641a882254d3b8c6eb52415e7be841a46a6eb (patch) | |
tree | 84f91a4e3e5cae14a4c76f10010a491dfc01c9c6 /Source/cmGlobalXCodeGenerator.cxx | |
parent | 1601b47b3e55e5de755412ced342a5bb75c4507a (diff) | |
parent | 428c1e429ffb320b64c19d3da32e0822ff1b1b8d (diff) | |
download | CMake-680641a882254d3b8c6eb52415e7be841a46a6eb.zip CMake-680641a882254d3b8c6eb52415e7be841a46a6eb.tar.gz CMake-680641a882254d3b8c6eb52415e7be841a46a6eb.tar.bz2 |
Merge topic 'xcode-extra-sources'
428c1e429f Xcode: Avoid mutating App Bundle targets during generation
b4385d5ccc Xcode: Factor out duplicate source group code into lambda
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3208
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2fc6121..db673bb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1146,6 +1146,13 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( // Add CMakeLists.txt file for user convenience. this->AddXCodeProjBuildRule(gtgt, classes); + // Add the Info.plist we are about to generate for an App Bundle. + if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) { + std::string plist = this->ComputeInfoPListLocation(gtgt); + cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(plist, true); + classes.push_back(sf); + } + std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); gtgt->ComputeObjectMapping(); @@ -2862,13 +2869,13 @@ bool cmGlobalXCodeGenerator::CreateGroups( continue; } - // add the soon to be generated Info.plist file as a source for a - // MACOSX_BUNDLE file - if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) { - std::string plist = this->ComputeInfoPListLocation(gtgt); - mf->GetOrCreateSource(plist, true); - gtgt->AddSource(plist); - } + auto addSourceToGroup = [this, mf, gtgt, + &sourceGroups](std::string const& source) { + cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups); + cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); + std::string key = GetGroupMapKeyFromPath(gtgt, source); + this->GroupMap[key] = pbxgroup; + }; // Put cmSourceFile instances in proper groups: for (auto const& si : gtgt->GetAllConfigSources()) { @@ -2877,12 +2884,7 @@ bool cmGlobalXCodeGenerator::CreateGroups( // Object library files go on the link line instead. continue; } - // Add the file to the list of sources. - std::string const& source = sf->GetFullPath(); - cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups); - cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); - std::string key = GetGroupMapKeyFromPath(gtgt, source); - this->GroupMap[key] = pbxgroup; + addSourceToGroup(sf->GetFullPath()); } // Add CMakeLists.txt file for user convenience. @@ -2891,11 +2893,14 @@ bool cmGlobalXCodeGenerator::CreateGroups( gtgt->GetLocalGenerator()->GetCurrentSourceDirectory(); listfile += "/CMakeLists.txt"; cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(listfile); - std::string const& source = sf->GetFullPath(); - cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups); - cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); - std::string key = GetGroupMapKeyFromPath(gtgt, source); - this->GroupMap[key] = pbxgroup; + addSourceToGroup(sf->GetFullPath()); + } + + // Add the Info.plist we are about to generate for an App Bundle. + if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) { + std::string plist = this->ComputeInfoPListLocation(gtgt); + cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(plist, true); + addSourceToGroup(sf->GetFullPath()); } } } |