diff options
author | Brad King <brad.king@kitware.com> | 2021-04-26 15:34:29 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-04-26 15:34:38 (GMT) |
commit | 395e1d458ed7ec84b0393ca31064018dc0bef575 (patch) | |
tree | 8a312b7f09f79a13b98252ba51b5b170dde17616 /Tests | |
parent | 3c1655936fec54e76d6f92ab6d37e2104db44699 (diff) | |
parent | eb5e33ba474e061b302cd0b3b1ecb62625489532 (diff) | |
download | CMake-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 'Tests')
13 files changed, 122 insertions, 40 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 5f23c05..5e16de0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -554,7 +554,7 @@ endif() if(XCODE_VERSION) add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}) - add_RunCMake_test(XcodeProject-Embed) + add_RunCMake_test(XcodeProject-Embed -DXCODE_VERSION=${XCODE_VERSION}) # This test can take a very long time due to lots of combinations. # Use a long default timeout and provide an option to customize it. diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake new file mode 100644 index 0000000..576be11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake new file mode 100644 index 0000000..839f842 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedAppExtensions.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake new file mode 100644 index 0000000..576be11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake new file mode 100644 index 0000000..839f842 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedAppExtensions.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake new file mode 100644 index 0000000..d7494ea --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake @@ -0,0 +1,21 @@ +add_library(app_extension MODULE Empty.txt) +set_target_properties(app_extension PROPERTIES + LINKER_LANGUAGE CXX + BUNDLE YES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app.app_extension" + XCODE_PRODUCT_TYPE "com.apple.product-type.app-extension" + XCODE_EXPLICIT_FILE_TYPE "wrapper.app-extension" +) + +add_executable(app MACOSX_BUNDLE main.m) +add_dependencies(app app_extension) +set_target_properties(app PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_EMBED_APP_EXTENSIONS app_extension + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app" +) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake index 9cc03b9..dbd3e87 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake @@ -1,14 +1,4 @@ -function(findAttribute project attr) - execute_process( - COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj - OUTPUT_VARIABLE output_var - RESULT_VARIABLE result_var - ) +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) - if(NOT result_var) - set(RunCMake_TEST_FAILED "${attr} attribute is set" PARENT_SCOPE) - endif() -endfunction() - -findAttribute(${test} "RemoveHeadersOnCopy") -findAttribute(${test} "CodeSignOnCopy") +findAttribute(${test} "RemoveHeadersOnCopy" FALSE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake index 3f62640..0f57820 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake @@ -1,14 +1,4 @@ -function(findAttribute project attr) - execute_process( - COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj - OUTPUT_VARIABLE output_var - RESULT_VARIABLE result_var - ) +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) - if(result_var) - set(RunCMake_TEST_FAILED "${attr} attribute not set" PARENT_SCOPE) - endif() -endfunction() - -findAttribute(${test} "RemoveHeadersOnCopy") -findAttribute(${test} "CodeSignOnCopy") +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake index 3f62640..0f57820 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake @@ -1,14 +1,4 @@ -function(findAttribute project attr) - execute_process( - COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj - OUTPUT_VARIABLE output_var - RESULT_VARIABLE result_var - ) +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) - if(result_var) - set(RunCMake_TEST_FAILED "${attr} attribute not set" PARENT_SCOPE) - endif() -endfunction() - -findAttribute(${test} "RemoveHeadersOnCopy") -findAttribute(${test} "CodeSignOnCopy") +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/Empty.txt b/Tests/RunCMake/XcodeProject-Embed/Empty.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/Empty.txt diff --git a/Tests/RunCMake/XcodeProject-Embed/Info.plist.in b/Tests/RunCMake/XcodeProject-Embed/Info.plist.in new file mode 100644 index 0000000..a26f316 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/Info.plist.in @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleDisplayName</key> + <string>SomeExtension</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>com.example.app.app_extension</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>app</string> + <key>CFBundlePackageType</key> + <string>XPC!</string> + <key>CFBundleShortVersionString</key> + <string>1.0.0</string> + <key>CFBundleVersion</key> + <string>1.0.0</string> + <key>NSExtension</key> + <dict> + <key>NSExtensionPointIdentifier</key> + <string>com.apple.widgetkit-extension</string> + <key>NSExtensionPrincipalClass</key> + <string>SomeExtensionBrowserViewController</string> + </dict> +</dict> +</plist> diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index 0dc1cf3..e94d084 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -41,3 +41,34 @@ endfunction() TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir) TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir) + + +function(TestAppExtension platform) + set(testName EmbedAppExtensions-${platform}) + if(NOT platform STREQUAL "macOS") + set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=${platform}) + endif() + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(${testName}) + run_cmake_command(${testName}-build + ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} + --config Debug + --target app + ) +endfunction() + +# Isolate device tests from host architecture selection. +unset(ENV{CMAKE_OSX_ARCHITECTURES}) + +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + # The various flag on/off combinations are tested by the EmbedFrameworks... + # tests, so we don't duplicate all the combinations here. We only verify the + # defaults, which is to remove headers on copy, but not code sign. + TestAppExtension(macOS) + TestAppExtension(iOS) +endif() diff --git a/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake b/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake new file mode 100644 index 0000000..b1963e2 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake @@ -0,0 +1,19 @@ +cmake_policy(VERSION 3.1...3.20) + +function(findAttribute project attr expectPresent) + execute_process( + COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj + OUTPUT_VARIABLE output_var + RESULT_VARIABLE result_var + ) + + if(${expectPresent}) + if(result_var) + set(RunCMake_TEST_FAILED "${attr} attribute is not set" PARENT_SCOPE) + endif() + else() + if(NOT result_var) + set(RunCMake_TEST_FAILED "${attr} attribute is set" PARENT_SCOPE) + endif() + endif() +endfunction() |