From 2b4bb43ed385cf57d38e21bc1f5971e59c73ce6c Mon Sep 17 00:00:00 2001 From: Jonathan Earnshaw Date: Tue, 28 Nov 2023 14:51:45 +1300 Subject: Xcode: Add support to embed XPC Services --- Help/prop_tgt/XCODE_EMBED_type.rst | 6 ++++++ Help/prop_tgt/XCODE_EMBED_type_PATH.rst | 3 +++ Help/release/dev/xcode-embed-xpc-services | 6 ++++++ Source/cmGlobalXCodeGenerator.cxx | 10 +++++++++ Source/cmGlobalXCodeGenerator.h | 1 + .../EmbedXPCServices-macOS-check.cmake | 3 +++ .../EmbedXPCServices-macOS.cmake | 1 + .../XcodeProject-Embed/EmbedXPCServices.cmake | 17 +++++++++++++++ .../RunCMake/XcodeProject-Embed/RunCMakeTest.cmake | 1 + .../XcodeProject-Embed/XPCService.Info.plist.in | 24 ++++++++++++++++++++++ 10 files changed, 72 insertions(+) create mode 100644 Help/release/dev/xcode-embed-xpc-services create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS-check.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/XPCService.Info.plist.in diff --git a/Help/prop_tgt/XCODE_EMBED_type.rst b/Help/prop_tgt/XCODE_EMBED_type.rst index e27d905..0f71ead 100644 --- a/Help/prop_tgt/XCODE_EMBED_type.rst +++ b/Help/prop_tgt/XCODE_EMBED_type.rst @@ -43,6 +43,12 @@ The supported values for ```` are: The specified items will be added to the ``Embed Resources`` build phase. They must be CMake target names or folder paths. +``XPC_SERVICES`` + .. versionadded:: 3.29 + + The specified items will be added to the ``Embed XPC Services`` build phase. + They must be CMake target names. + See also :prop_tgt:`XCODE_EMBED__PATH`, :prop_tgt:`XCODE_EMBED__REMOVE_HEADERS_ON_COPY` and :prop_tgt:`XCODE_EMBED__CODE_SIGN_ON_COPY`. diff --git a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst index ef04d14..255aa68 100644 --- a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst +++ b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst @@ -25,3 +25,6 @@ The supported values for ```` are: ``RESOURCES`` .. versionadded:: 3.28 + +``XPC_SERVICES`` + .. versionadded:: 3.29 diff --git a/Help/release/dev/xcode-embed-xpc-services b/Help/release/dev/xcode-embed-xpc-services new file mode 100644 index 0000000..f758285 --- /dev/null +++ b/Help/release/dev/xcode-embed-xpc-services @@ -0,0 +1,6 @@ +xcode-embed-xpc-services +------------------------ + +* The :prop_tgt:`XCODE_EMBED_XPC_SERVICES >` target property + was added to tell the :generator:`Xcode` generator what targets to put in + the ``Embed XPC Resources`` build phase. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 89c94e2..b51af0b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -4299,6 +4299,15 @@ void cmGlobalXCodeGenerator::AddEmbeddedResources(cmXCodeObject* target) dstSubfolderSpec, NoActionOnCopyByDefault); } +void cmGlobalXCodeGenerator::AddEmbeddedXPCServices(cmXCodeObject* target) +{ + static const auto dstSubfolderSpec = "16"; + + this->AddEmbeddedObjects( + target, "Embed XPC Services", "XCODE_EMBED_XPC_SERVICES", dstSubfolderSpec, + NoActionOnCopyByDefault, "$(CONTENTS_FOLDER_PATH)/XPCServices"); +} + bool cmGlobalXCodeGenerator::CreateGroups( std::vector& generators) { @@ -4712,6 +4721,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->AddEmbeddedAppExtensions(t); this->AddEmbeddedExtensionKitExtensions(t); this->AddEmbeddedResources(t); + this->AddEmbeddedXPCServices(t); // Inherit project-wide values for any target-specific search paths. this->InheritBuildSettingAttribute(t, "HEADER_SEARCH_PATHS"); this->InheritBuildSettingAttribute(t, "SYSTEM_HEADER_SEARCH_PATHS"); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index da0a4ea..12a5cad 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -225,6 +225,7 @@ private: void AddEmbeddedAppExtensions(cmXCodeObject* target); void AddEmbeddedExtensionKitExtensions(cmXCodeObject* target); void AddEmbeddedResources(cmXCodeObject* target); + void AddEmbeddedXPCServices(cmXCodeObject* target); void AddPositionIndependentLinkAttribute(cmGeneratorTarget* target, cmXCodeObject* buildSettings, const std::string& configName); diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS-check.cmake new file mode 100644 index 0000000..706add5 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS-check.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "Embed XPC Services" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS.cmake new file mode 100644 index 0000000..5ad0436 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices-macOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedXPCServices.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices.cmake new file mode 100644 index 0000000..877a685 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedXPCServices.cmake @@ -0,0 +1,17 @@ +add_executable(xpc_service MACOSX_BUNDLE main.m) +set_target_properties(xpc_service PROPERTIES + BUNDLE_EXTENSION "xpc" + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/XPCService.Info.plist.in" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app.xpc_service" +) + +add_executable(app MACOSX_BUNDLE main.m) +add_dependencies(app xpc_service) +set_target_properties(app PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_EMBED_XPC_SERVICES xpc_service + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app" +) diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index 3798ddc..77ac63f 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -122,4 +122,5 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 14.1) TestEmbedCommon(Resources macOS) TestEmbedCommon(Resources iOS) TestEmbedCommon(PlugIns macOS) + TestEmbedCommon(XPCServices macOS) endif() diff --git a/Tests/RunCMake/XcodeProject-Embed/XPCService.Info.plist.in b/Tests/RunCMake/XcodeProject-Embed/XPCService.Info.plist.in new file mode 100644 index 0000000..abc8db2 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/XPCService.Info.plist.in @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + SomeExtension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.example.app.xpc_service + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + example_app_xpc_service + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0.0 + CFBundleVersion + 1.0.0 + + -- cgit v0.12