summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-04-26 15:34:29 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-04-26 15:34:38 (GMT)
commit395e1d458ed7ec84b0393ca31064018dc0bef575 (patch)
tree8a312b7f09f79a13b98252ba51b5b170dde17616 /Source/cmGlobalXCodeGenerator.cxx
parent3c1655936fec54e76d6f92ab6d37e2104db44699 (diff)
parenteb5e33ba474e061b302cd0b3b1ecb62625489532 (diff)
downloadCMake-395e1d458ed7ec84b0393ca31064018dc0bef575.zip
CMake-395e1d458ed7ec84b0393ca31064018dc0bef575.tar.gz
CMake-395e1d458ed7ec84b0393ca31064018dc0bef575.tar.bz2
Merge topic 'xcode_app_extensions'
eb5e33ba47 Xcode: Add support for embedding app extensions f62a2bf44f Tests: Factor out XcodeProject-Embed check function findAttribute() Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5934
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx71
1 files changed, 51 insertions, 20 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 92dd555..d6909c3 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3777,7 +3777,10 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
}
}
-void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
+void cmGlobalXCodeGenerator::AddEmbeddedObjects(
+ cmXCodeObject* target, const std::string& copyFilesBuildPhaseName,
+ const std::string& embedPropertyName, const std::string& dstSubfolderSpec,
+ int actionsOnByDefault)
{
cmGeneratorTarget* gt = target->GetTarget();
if (!gt) {
@@ -3793,7 +3796,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
if (!(isFrameworkTarget || isBundleTarget || isCFBundleTarget)) {
return;
}
- cmProp files = gt->GetProperty("XCODE_EMBED_FRAMEWORKS");
+ cmProp files = gt->GetProperty(embedPropertyName);
if (!files) {
return;
}
@@ -3801,16 +3804,15 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
// Create an "Embedded Frameworks" build phase
auto* copyFilesBuildPhase =
this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
- std::string copyFilesBuildPhaseName = "Embed Frameworks";
- std::string destinationFrameworks = "10";
copyFilesBuildPhase->SetComment(copyFilesBuildPhaseName);
copyFilesBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
- this->CreateString(destinationFrameworks));
+ this->CreateString(dstSubfolderSpec));
copyFilesBuildPhase->AddAttribute(
"name", this->CreateString(copyFilesBuildPhaseName));
- if (cmProp fwEmbedPath = gt->GetProperty("XCODE_EMBED_FRAMEWORKS_PATH")) {
+ if (cmProp fwEmbedPath =
+ gt->GetProperty(cmStrCat(embedPropertyName, "_PATH"))) {
copyFilesBuildPhase->AddAttribute("dstPath",
this->CreateString(*fwEmbedPath));
} else {
@@ -3824,10 +3826,10 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
for (std::string const& relFile : relFiles) {
cmXCodeObject* buildFile{ nullptr };
std::string filePath = relFile;
- auto* genTarget = FindGeneratorTarget(relFile);
+ auto* genTarget = this->FindGeneratorTarget(relFile);
if (genTarget) {
// This is a target - get it's product path reference
- auto* xcTarget = FindXCodeTarget(genTarget);
+ auto* xcTarget = this->FindXCodeTarget(genTarget);
if (!xcTarget) {
cmSystemTools::Error("Can not find a target for " +
genTarget->GetName());
@@ -3841,18 +3843,18 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
" is missing product reference");
continue;
}
- auto it = FileRefToEmbedBuildFileMap.find(fileRefObject);
- if (it == FileRefToEmbedBuildFileMap.end()) {
+ auto it = this->FileRefToEmbedBuildFileMap.find(fileRefObject);
+ if (it == this->FileRefToEmbedBuildFileMap.end()) {
buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
buildFile->AddAttribute("fileRef", fileRefObject);
- FileRefToEmbedBuildFileMap[fileRefObject] = buildFile;
+ this->FileRefToEmbedBuildFileMap[fileRefObject] = buildFile;
} else {
buildFile = it->second;
}
} else if (cmSystemTools::IsPathToFramework(relFile)) {
// This is a regular string path - create file reference
- auto it = EmbeddedLibRefs.find(relFile);
- if (it == EmbeddedLibRefs.end()) {
+ auto it = this->EmbeddedLibRefs.find(relFile);
+ if (it == this->EmbeddedLibRefs.end()) {
cmXCodeObject* fileRef =
this->CreateXCodeFileReferenceFromPath(relFile, gt, "", nullptr);
if (fileRef) {
@@ -3878,16 +3880,25 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
cmXCodeObject* settings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- const auto& rmHeadersProp =
- gt->GetSafeProperty("XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY");
- if (cmIsOn(rmHeadersProp)) {
+
+ bool removeHeaders = actionsOnByDefault & RemoveHeadersOnCopyByDefault;
+ if (auto prop = gt->GetProperty(
+ cmStrCat(embedPropertyName, "_REMOVE_HEADERS_ON_COPY"))) {
+ removeHeaders = cmIsOn(*prop);
+ }
+ if (removeHeaders) {
attrs->AddObject(this->CreateString("RemoveHeadersOnCopy"));
}
- const auto& codeSignProp =
- gt->GetSafeProperty("XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY");
- if (cmIsOn(codeSignProp)) {
+
+ bool codeSign = actionsOnByDefault & CodeSignOnCopyByDefault;
+ if (auto prop =
+ gt->GetProperty(cmStrCat(embedPropertyName, "_CODE_SIGN_ON_COPY"))) {
+ codeSign = cmIsOn(*prop);
+ }
+ if (codeSign) {
attrs->AddObject(this->CreateString("CodeSignOnCopy"));
}
+
settings->AddAttributeIfNotEmpty("ATTRIBUTES", attrs);
buildFile->AddAttributeIfNotEmpty("settings", settings);
if (!buildFiles->HasObject(buildFile)) {
@@ -3896,11 +3907,30 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
}
copyFilesBuildPhase->AddAttribute("files", buildFiles);
auto* buildPhases = target->GetAttribute("buildPhases");
- // Insert embed build phase right before the post-build command
+ // Embed-something build phases must be inserted before the post-build
+ // command because that command is expected to be last
buildPhases->InsertObject(buildPhases->GetObjectCount() - 1,
copyFilesBuildPhase);
}
+void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target)
+{
+ static const auto dstSubfolderSpec = "10";
+
+ this->AddEmbeddedObjects(target, "Embed Frameworks",
+ "XCODE_EMBED_FRAMEWORKS", dstSubfolderSpec,
+ NoActionOnCopyByDefault);
+}
+
+void cmGlobalXCodeGenerator::AddEmbeddedAppExtensions(cmXCodeObject* target)
+{
+ static const auto dstSubfolderSpec = "13";
+
+ this->AddEmbeddedObjects(target, "Embed App Extensions",
+ "XCODE_EMBED_APP_EXTENSIONS", dstSubfolderSpec,
+ RemoveHeadersOnCopyByDefault);
+}
+
bool cmGlobalXCodeGenerator::CreateGroups(
std::vector<cmLocalGenerator*>& generators)
{
@@ -4280,6 +4310,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
for (auto t : targets) {
this->AddDependAndLinkInformation(t);
this->AddEmbeddedFrameworks(t);
+ this->AddEmbeddedAppExtensions(t);
// Inherit project-wide values for any target-specific search paths.
this->InheritBuildSettingAttribute(t, "HEADER_SEARCH_PATHS");
this->InheritBuildSettingAttribute(t, "SYSTEM_HEADER_SEARCH_PATHS");