summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-10 12:04:15 (GMT)
committerBrad King <brad.king@kitware.com>2019-04-11 14:35:14 (GMT)
commit428c1e429ffb320b64c19d3da32e0822ff1b1b8d (patch)
tree8531fbe7e3b256ed5216cf02a065a5a18673ecab /Source/cmGlobalXCodeGenerator.cxx
parentb4385d5ccc0241f8adcb012ad645d3696bcc544c (diff)
downloadCMake-428c1e429ffb320b64c19d3da32e0822ff1b1b8d.zip
CMake-428c1e429ffb320b64c19d3da32e0822ff1b1b8d.tar.gz
CMake-428c1e429ffb320b64c19d3da32e0822ff1b1b8d.tar.bz2
Xcode: Avoid mutating App Bundle targets during generation
For `MACOSX_BUNDLE` targets we generate an `Info.plist` automatically and add it to the sources presented to Xcode. Avoid mutating the original target's list of sources to achieve this. Otherwise when we generate the same target again (e.g. in a sub-project's Xcode file) it will look different than the first time and possibly break invariants. Fixes: #19114
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx22
1 files changed, 14 insertions, 8 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index dd6008f..57de60e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1142,6 +1142,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();
@@ -2883,14 +2890,6 @@ bool cmGlobalXCodeGenerator::CreateGroups(
this->GroupMap[key] = pbxgroup;
};
- // 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);
- }
-
// Put cmSourceFile instances in proper groups:
for (auto const& si : gtgt->GetAllConfigSources()) {
cmSourceFile const* sf = si.Source;
@@ -2909,6 +2908,13 @@ bool cmGlobalXCodeGenerator::CreateGroups(
cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(listfile);
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());
+ }
}
}
return true;