diff options
author | Brad King <brad.king@kitware.com> | 2019-02-05 12:30:19 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-05 12:33:04 (GMT) |
commit | c03072f2f7a08c6ddf0cec58dfc8ea2b83f4c1a9 (patch) | |
tree | afb2c6960e306ed36217f0cc6a1f7cad15d9ed3d /Tests | |
parent | 25e616862dac08aae7c4a3ad01839acfe7342ec7 (diff) | |
parent | e8ee8cab97bdb084d4555ee3e76eb33303e3bc85 (diff) | |
download | CMake-c03072f2f7a08c6ddf0cec58dfc8ea2b83f4c1a9.zip CMake-c03072f2f7a08c6ddf0cec58dfc8ea2b83f4c1a9.tar.gz CMake-c03072f2f7a08c6ddf0cec58dfc8ea2b83f4c1a9.tar.bz2 |
Merge topic '17870-iphone-friendly-cmake'
e8ee8cab97 Xcode: Completely disable code signing for compiler id detection
11da882a12 Apple: Introduce separate system name for iOS, tvOS, and watchOS
36cf44a7a3 Tests: Isolate RunCMake.XcodeProject per-device cases from host arch
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2392
Diffstat (limited to 'Tests')
7 files changed, 73 insertions, 94 deletions
diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake index 6281352..288735e 100644 --- a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake +++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake @@ -3,28 +3,21 @@ project(DeploymentTarget C) # using Xcode 7.1 SDK versions for deployment targets -if(SDK MATCHES iphone) - set(CMAKE_OSX_SYSROOT ${SDK}) - set(CMAKE_OSX_ARCHITECTURES "armv7;x86_64") +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "9.1") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -elseif(SDK MATCHES watch) - set(CMAKE_OSX_SYSROOT ${SDK}) - set(CMAKE_OSX_ARCHITECTURES "armv7k;i386") +elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") -elseif(SDK MATCHES appletv) - set(CMAKE_OSX_SYSROOT ${SDK}) +elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "9.0") - set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") else() - set(CMAKE_OSX_SYSROOT ${SDK}) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11") endif() diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index fb04005..4918f7c 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -1,9 +1,5 @@ include(RunCMake) -if(XCODE_VERSION VERSION_GREATER_EQUAL 9) - set(IOS_DEPLOYMENT_TARGET "-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=10") -endif() - run_cmake(ExplicitCMakeLists) run_cmake(XcodeFileType) @@ -25,14 +21,48 @@ run_cmake(PerConfigPerSourceOptions) run_cmake(PerConfigPerSourceDefinitions) run_cmake(PerConfigPerSourceIncludeDirs) +function(XcodeSchemaGeneration) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeSchemaGeneration) + run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build) +endfunction() + +if(NOT XCODE_VERSION VERSION_LESS 7) + XcodeSchemaGeneration() + run_cmake(XcodeSchemaProperty) +endif() + +function(XcodeDependOnZeroCheck) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeDependOnZeroCheck) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib) +endfunction() + +XcodeDependOnZeroCheck() + +# Isolate device tests from host architecture selection. +unset(ENV{CMAKE_OSX_ARCHITECTURES}) + # Use a single build tree for a few tests without cleaning. if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -47,7 +77,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_IOS=OFF" + "-DCMAKE_SYSTEM_NAME=Darwin" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -64,9 +94,8 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_IOS=ON" - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -84,7 +113,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesWatchOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_WATCHOS=ON" + "-DCMAKE_SYSTEM_NAME=watchOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -103,7 +132,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesTvOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_TVOS=ON" + "-DCMAKE_SYSTEM_NAME=tvOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -129,9 +158,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_IOS_INSTALL_COMBINED=YES" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -148,9 +177,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_IOS_INSTALL_COMBINED=YES" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -167,9 +196,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedSingleArch-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_IOS_INSTALL_COMBINED=YES" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -205,28 +234,11 @@ if(NOT XCODE_VERSION VERSION_LESS 5) unset(RunCMake_TEST_OPTIONS) endif() -function(XcodeSchemaGeneration) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON") - - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - - run_cmake(XcodeSchemaGeneration) - run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build) -endfunction() - -if(NOT XCODE_VERSION VERSION_LESS 7) - XcodeSchemaGeneration() - run_cmake(XcodeSchemaProperty) -endif() - if(XCODE_VERSION VERSION_GREATER_EQUAL 8) - function(deploymeny_target_test SDK) + function(deployment_target_test SystemName SDK) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DeploymentTarget-${SDK}-build) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DSDK=${SDK}") + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -235,21 +247,13 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) run_cmake_command(DeploymentTarget-${SDK} ${CMAKE_COMMAND} --build .) endfunction() - foreach(SDK macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator) - deploymeny_target_test(${SDK}) - endforeach() + deployment_target_test(Darwin macosx) + deployment_target_test(iOS iphoneos) + deployment_target_test(iOS iphonesimulator) + deployment_target_test(tvOS appletvos) + deployment_target_test(tvOS appletvsimulator) + deployment_target_test(watchOS watchos) + deployment_target_test(watchOS watchsimulator) endif() -function(XcodeDependOnZeroCheck) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build) - set(RunCMake_TEST_NO_CLEAN 1) - - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - - run_cmake(XcodeDependOnZeroCheck) - run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib) - run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib) -endfunction() - -XcodeDependOnZeroCheck() +# Please add macOS-only tests above before the device-specific tests. diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index 5d19ee8..ef772ea 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -3,27 +3,12 @@ cmake_minimum_required(VERSION 3.3) enable_language(C) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) - -if(TEST_IOS) - set(CMAKE_OSX_SYSROOT iphoneos) - set(CMAKE_OSX_ARCHITECTURES "armv7") +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -endif(TEST_IOS) - -if(TEST_WATCHOS) - set(CMAKE_OSX_SYSROOT watchos) - set(CMAKE_OSX_ARCHITECTURES "armv7k") - set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") - set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") - set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") endif() -if(TEST_TVOS) - set(CMAKE_OSX_SYSROOT appletvos) - set(CMAKE_OSX_ARCHITECTURES "arm64") +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") @@ -41,7 +26,7 @@ add_dependencies(AppBundleTest AppBundle) # with custom extension -if (NOT TEST_IOS AND NOT TEST_WATCHOS AND NOT TEST_TVOS) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_executable(AppBundleExt MACOSX_BUNDLE main.m) set_target_properties(AppBundleExt PROPERTIES BUNDLE_EXTENSION "foo") install(TARGETS AppBundleExt BUNDLE DESTINATION FooExtension) @@ -55,7 +40,7 @@ endif() # Shared Framework (not supported for iOS on Xcode < 6) -if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" OR NOT XCODE_VERSION VERSION_LESS 6) add_library(SharedFramework SHARED main.c) set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake index d7f3920..7f31d94 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(IOSInstallCombined CXX) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() -set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake index 28ab883..ec11dbb 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(XcodeIOSInstallCombinedPrune CXX) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() -set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake index 5e7961a..58e96b4 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(XcodeIOSInstallCombinedSingleArch CXX) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() -set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake index a797410..ab31387 100644 --- a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake @@ -2,11 +2,8 @@ cmake_minimum_required(VERSION 2.8.5) project(XcodeInstallIOS) -set(CMAKE_OSX_SYSROOT iphoneos) set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -set(CMAKE_OSX_ARCHITECTURES "armv7;i386") - add_library(foo STATIC foo.cpp) install(TARGETS foo ARCHIVE DESTINATION lib) |