mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
Apple: Introduce separate system name for iOS, tvOS, and watchOS
- Remove code signing requirements for non-macOS - Do not set deployment target for non-macOS - Build static library for compiler feature detection for non-macOS - Use framework to run CompilerId tests for watchOS - Port tests to new SDK handling - Add new Apple cross-compiling section to toolchain documentation Closes: #17870
This commit is contained in:
@@ -522,3 +522,72 @@ 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.
|
||||
|
||||
.. _`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.
|
||||
|
||||
5
Help/release/dev/iphone-friendly-cmake.rst
Normal file
5
Help/release/dev/iphone-friendly-cmake.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
iphone-friendly-cmake
|
||||
---------------------
|
||||
|
||||
* CMake now supports :ref:`Cross Compiling for iOS, tvOS, or watchOS`
|
||||
using simple toolchain files.
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -352,6 +352,8 @@ 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 "")
|
||||
@@ -366,7 +368,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
|
||||
set(id_code_sign_identity
|
||||
"CODE_SIGN_IDENTITY = \"${CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}\";")
|
||||
else()
|
||||
set(id_code_sign_identity "")
|
||||
set(id_code_sign_identity "CODE_SIGN_IDENTITY = \"\";")
|
||||
endif()
|
||||
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in
|
||||
${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY)
|
||||
@@ -491,6 +493,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 "")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 "[^;]"
|
||||
|
||||
@@ -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)
|
||||
|
||||
1
Modules/Platform/iOS-Determine-CXX.cmake
Normal file
1
Modules/Platform/iOS-Determine-CXX.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin-Determine-CXX)
|
||||
7
Modules/Platform/iOS-Initialize.cmake
Normal file
7
Modules/Platform/iOS-Initialize.cmake
Normal file
@@ -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)
|
||||
1
Modules/Platform/iOS.cmake
Normal file
1
Modules/Platform/iOS.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin)
|
||||
1
Modules/Platform/tvOS-Determine-CXX.cmake
Normal file
1
Modules/Platform/tvOS-Determine-CXX.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin-Determine-CXX)
|
||||
7
Modules/Platform/tvOS-Initialize.cmake
Normal file
7
Modules/Platform/tvOS-Initialize.cmake
Normal file
@@ -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)
|
||||
1
Modules/Platform/tvOS.cmake
Normal file
1
Modules/Platform/tvOS.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin)
|
||||
1
Modules/Platform/watchOS-Determine-CXX.cmake
Normal file
1
Modules/Platform/watchOS-Determine-CXX.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin-Determine-CXX)
|
||||
7
Modules/Platform/watchOS-Initialize.cmake
Normal file
7
Modules/Platform/watchOS-Initialize.cmake
Normal file
@@ -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)
|
||||
1
Modules/Platform/watchOS.cmake
Normal file
1
Modules/Platform/watchOS.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin)
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -65,8 +61,8 @@ 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}")
|
||||
@@ -81,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}")
|
||||
@@ -98,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}")
|
||||
@@ -118,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}")
|
||||
@@ -137,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}")
|
||||
@@ -163,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}")
|
||||
@@ -182,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}")
|
||||
@@ -201,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}")
|
||||
@@ -240,10 +235,10 @@ if(NOT XCODE_VERSION VERSION_LESS 5)
|
||||
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}")
|
||||
@@ -252,9 +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()
|
||||
|
||||
# Please add macOS-only tests above before the device-specific tests.
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user