summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-toolchains.7.rst71
-rw-r--r--Help/release/dev/iphone-friendly-cmake.rst5
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake17
-rw-r--r--Modules/CMakeTestCCompiler.cmake8
-rw-r--r--Modules/CMakeTestCXXCompiler.cmake8
-rw-r--r--Modules/CompilerId/Xcode-3.pbxproj.in3
-rw-r--r--Modules/Platform/Darwin-Initialize.cmake8
-rw-r--r--Modules/Platform/Darwin.cmake8
-rw-r--r--Modules/Platform/iOS-Determine-CXX.cmake1
-rw-r--r--Modules/Platform/iOS-Initialize.cmake7
-rw-r--r--Modules/Platform/iOS.cmake1
-rw-r--r--Modules/Platform/tvOS-Determine-CXX.cmake1
-rw-r--r--Modules/Platform/tvOS-Initialize.cmake7
-rw-r--r--Modules/Platform/tvOS.cmake1
-rw-r--r--Modules/Platform/watchOS-Determine-CXX.cmake1
-rw-r--r--Modules/Platform/watchOS-Initialize.cmake7
-rw-r--r--Modules/Platform/watchOS.cmake1
-rw-r--r--Tests/RunCMake/XcodeProject/DeploymentTarget.cmake13
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake110
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeBundles.cmake23
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake3
26 files changed, 215 insertions, 111 deletions
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index 8554e87..d214e4a 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -522,3 +522,74 @@ See also target properties:
* :prop_tgt:`ANDROID_SECURE_PROPS_PATH`
* :prop_tgt:`ANDROID_SKIP_ANT_STEP`
* :prop_tgt:`ANDROID_STL_TYPE`
+
+.. _`Cross Compiling for iOS, tvOS, or watchOS`:
+
+Cross Compiling for iOS, tvOS, or watchOS
+-----------------------------------------
+
+For cross-compiling to iOS, tvOS, or watchOS, the :generator:`Xcode`
+generator is recommended. The :generator:`Unix Makefiles` or
+:generator:`Ninja` generators can also be used, but they require the
+project to handle more areas like target CPU selection and code signing.
+
+Any of the three systems can be targetted by setting the
+:variable:`CMAKE_SYSTEM_NAME` variable to a value from the table below.
+By default, the latest Device SDK is chosen. As for all Apple platforms,
+a different SDK (e.g. a simulator) can be selected by setting the
+:variable:`CMAKE_OSX_SYSROOT` variable, although this should rarely be
+necessary (see :ref:`Switching Between Device and Simulator` below).
+A list of available SDKs can be obtained by running ``xcodebuild -showsdks``.
+
+======= ================= ==================== ================
+OS CMAKE_SYSTEM_NAME Device SDK (default) Simulator SDK
+======= ================= ==================== ================
+iOS iOS iphoneos iphonesimulator
+tvOS tvOS appletvos appletvsimulator
+watchOS watchOS watchos watchsimulator
+======= ================= ==================== ================
+
+For example, to create a CMake configuration for iOS, the following
+command is sufficient:
+
+.. code-block:: console
+
+ cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS
+
+Code Signing
+^^^^^^^^^^^^
+
+Some build artifacts for the embedded Apple platforms require mandatory
+code signing. If the :generator:`Xcode` generator is being used and
+code signing is required or desired, the developmemt team ID can be
+specified via the ``CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM`` CMake variable.
+This team ID will then be included in the generated Xcode project.
+By default, CMake avoids the need for code signing during the internal
+configuration phase (i.e compiler ID and feature detection).
+
+.. _`Switching Between Device and Simulator`:
+
+Switching Between Device and Simulator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+When configuring for any of the embedded platforms, one can target either
+real devices or the simulator. Both have their own separate SDK, but CMake
+only supports specifying a single SDK for the configuration phase. This
+means the developer must select one or the other at configuration time.
+When using the :generator:`Xcode` generator, this is less of a limitation
+because Xcode still allows you to build for either a device or a simulator,
+even though configuration was only performed for one of the two. From
+within the Xcode IDE, builds are performed for the selected "destination"
+platform. When building from the command line, the desired sdk can be
+specified directly by passing a ``-sdk`` option to the underlying build
+tool (``xcodebuild``). For example:
+
+.. code-block:: console
+
+ $ cmake --build ... -- -sdk iphonesimulator
+
+Please note that checks made during configuration were performed against
+the configure-time SDK and might not hold true for other SDKs. Commands
+like :command:`find_package`, :command:`find_library`, etc. store and use
+details only for the configured SDK/platform, so they can be problematic
+if wanting to switch between device and simulator builds.
diff --git a/Help/release/dev/iphone-friendly-cmake.rst b/Help/release/dev/iphone-friendly-cmake.rst
new file mode 100644
index 0000000..f32f0d1
--- /dev/null
+++ b/Help/release/dev/iphone-friendly-cmake.rst
@@ -0,0 +1,5 @@
+iphone-friendly-cmake
+---------------------
+
+* CMake now supports :ref:`Cross Compiling for iOS, tvOS, or watchOS`
+ using simple toolchain files.
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 4f355f3..d7f6f97 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -106,7 +106,7 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
# ...
# /path/to/cc ...CompilerIdC/...
# to extract the compiler front-end for the language.
- set(CMAKE_C_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdC/(\\./)?(CompilerIdC.xctest/)?CompilerIdC[ \t\n\\\"]")
+ set(CMAKE_C_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdC/(\\./)?(CompilerIdC.(framework|xctest)/)?CompilerIdC[ \t\n\\\"]")
set(CMAKE_C_COMPILER_ID_TOOL_MATCH_INDEX 2)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index 96b4209..bd878b2 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -101,7 +101,7 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN)
# ...
# /path/to/cc ...CompilerIdCXX/...
# to extract the compiler front-end for the language.
- set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.xctest/)?CompilerIdCXX[ \t\n\\\"]")
+ set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.(framework|xctest)/)?CompilerIdCXX[ \t\n\\\"]")
set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index cdbaea6..2f84c8e 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -354,22 +354,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]" OR
CMAKE_OSX_SYSROOT MATCHES "(^|/)[Aa][Pp][Pp][Ll][Ee][Tt][Vv]")
set(id_product_type "com.apple.product-type.bundle.unit-test")
+ elseif(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ww][Aa][Tt][Cc][Hh]")
+ set(id_product_type "com.apple.product-type.framework")
endif()
else()
set(id_sdkroot "")
endif()
- if(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
- set(id_development_team
- "DEVELOPMENT_TEAM = \"${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}\";")
- else()
- set(id_development_team "")
- endif()
- if(DEFINED CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY)
- set(id_code_sign_identity
- "CODE_SIGN_IDENTITY = \"${CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}\";")
- else()
- set(id_code_sign_identity "")
- endif()
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in
${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY)
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
@@ -493,6 +483,9 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
# com.apple.package-type.bundle.unit-test
${_glob_id_dir}/*.xctest/*
+
+ # com.apple.product-type.framework
+ ${_glob_id_dir}/*.framework/*
)
list(REMOVE_ITEM files "${src}")
set(COMPILER_${lang}_PRODUCED_FILES "")
diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake
index f74a1c6..7bf6fde 100644
--- a/Modules/CMakeTestCCompiler.cmake
+++ b/Modules/CMakeTestCCompiler.cmake
@@ -11,6 +11,12 @@ endif()
include(CMakeTestCompilerCommon)
+# work around enforced code signing and / or missing exectuable target type
+set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE})
+endif()
+
# Remove any cached result from an older CMake version.
# We now store this in CMakeCCompiler.cmake.
unset(CMAKE_C_COMPILER_WORKS CACHE)
@@ -86,4 +92,6 @@ else()
endif()
endif()
+set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})
+unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE)
unset(__CMAKE_C_COMPILER_OUTPUT)
diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake
index fe6bd25..7e595b7 100644
--- a/Modules/CMakeTestCXXCompiler.cmake
+++ b/Modules/CMakeTestCXXCompiler.cmake
@@ -11,6 +11,12 @@ endif()
include(CMakeTestCompilerCommon)
+# work around enforced code signing and / or missing exectuable target type
+set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE})
+endif()
+
# Remove any cached result from an older CMake version.
# We now store this in CMakeCXXCompiler.cmake.
unset(CMAKE_CXX_COMPILER_WORKS CACHE)
@@ -79,4 +85,6 @@ else()
endif()
endif()
+set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})
+unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE)
unset(__CMAKE_CXX_COMPILER_OUTPUT)
diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in
index 4686b64..813c074 100644
--- a/Modules/CompilerId/Xcode-3.pbxproj.in
+++ b/Modules/CompilerId/Xcode-3.pbxproj.in
@@ -72,8 +72,7 @@
1DEB928608733DD80010E9CD = {
isa = XCBuildConfiguration;
buildSettings = {
- @id_development_team@
- @id_code_sign_identity@
+ CODE_SIGN_IDENTITY = "";
PRODUCT_NAME = CompilerId@id_lang@;
};
name = Debug;
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index 3db77aa..2d797f6 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -34,7 +34,7 @@ string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1"
# CMAKE_OSX_DEPLOYMENT_TARGET
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
-if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND _CURRENT_OSX_VERSION VERSION_GREATER 10.3)
set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING
"Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
endif()
@@ -49,6 +49,12 @@ elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND
(NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}"))
# Use the value of SDKROOT from the environment.
set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}")
+elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
+ set(_CMAKE_OSX_SYSROOT_DEFAULT "iphoneos")
+elseif(CMAKE_SYSTEM_NAME STREQUAL tvOS)
+ set(_CMAKE_OSX_SYSROOT_DEFAULT "appletvos")
+elseif(CMAKE_SYSTEM_NAME STREQUAL watchOS)
+ set(_CMAKE_OSX_SYSROOT_DEFAULT "watchos")
elseif("${CMAKE_GENERATOR}" MATCHES Xcode
OR CMAKE_OSX_DEPLOYMENT_TARGET
OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 727baa6..a73ffba 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -1,5 +1,13 @@
set(APPLE 1)
+if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
+ set(CMAKE_MACOSX_BUNDLE ON)
+
+ set(CMAKE_FIND_ROOT_PATH "${_CMAKE_OSX_SYSROOT_PATH}")
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+endif()
+
# Darwin versions:
# 6.x == Mac OSX 10.2 (Jaguar)
# 7.x == Mac OSX 10.3 (Panther)
diff --git a/Modules/Platform/iOS-Determine-CXX.cmake b/Modules/Platform/iOS-Determine-CXX.cmake
new file mode 100644
index 0000000..ac80fa6
--- /dev/null
+++ b/Modules/Platform/iOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/iOS-Initialize.cmake b/Modules/Platform/iOS-Initialize.cmake
new file mode 100644
index 0000000..41399a3
--- /dev/null
+++ b/Modules/Platform/iOS-Initialize.cmake
@@ -0,0 +1,7 @@
+include(Platform/Darwin-Initialize)
+
+if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhone(OS|Simulator)")
+ message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an iOS SDK")
+endif()
+
+set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
diff --git a/Modules/Platform/iOS.cmake b/Modules/Platform/iOS.cmake
new file mode 100644
index 0000000..850ddc2
--- /dev/null
+++ b/Modules/Platform/iOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
diff --git a/Modules/Platform/tvOS-Determine-CXX.cmake b/Modules/Platform/tvOS-Determine-CXX.cmake
new file mode 100644
index 0000000..ac80fa6
--- /dev/null
+++ b/Modules/Platform/tvOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/tvOS-Initialize.cmake b/Modules/Platform/tvOS-Initialize.cmake
new file mode 100644
index 0000000..6834c80
--- /dev/null
+++ b/Modules/Platform/tvOS-Initialize.cmake
@@ -0,0 +1,7 @@
+include(Platform/Darwin-Initialize)
+
+if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTV(OS|Simulator)")
+ message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an tvOS SDK")
+endif()
+
+set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
diff --git a/Modules/Platform/tvOS.cmake b/Modules/Platform/tvOS.cmake
new file mode 100644
index 0000000..850ddc2
--- /dev/null
+++ b/Modules/Platform/tvOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
diff --git a/Modules/Platform/watchOS-Determine-CXX.cmake b/Modules/Platform/watchOS-Determine-CXX.cmake
new file mode 100644
index 0000000..ac80fa6
--- /dev/null
+++ b/Modules/Platform/watchOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/watchOS-Initialize.cmake b/Modules/Platform/watchOS-Initialize.cmake
new file mode 100644
index 0000000..2f396d3
--- /dev/null
+++ b/Modules/Platform/watchOS-Initialize.cmake
@@ -0,0 +1,7 @@
+include(Platform/Darwin-Initialize)
+
+if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/Watch(OS|Simulator)")
+ message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an watchOS SDK")
+endif()
+
+set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
diff --git a/Modules/Platform/watchOS.cmake b/Modules/Platform/watchOS.cmake
new file mode 100644
index 0000000..850ddc2
--- /dev/null
+++ b/Modules/Platform/watchOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
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)