mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 20:00:38 -06:00
apple: add preliminary visionOS support
This commit is contained in:
@@ -573,12 +573,12 @@ See also target properties:
|
||||
* :prop_tgt:`ANDROID_SKIP_ANT_STEP`
|
||||
* :prop_tgt:`ANDROID_STL_TYPE`
|
||||
|
||||
.. _`Cross Compiling for iOS, tvOS, or watchOS`:
|
||||
.. _`Cross Compiling for iOS, tvOS, visionOS, or watchOS`:
|
||||
|
||||
Cross Compiling for iOS, tvOS, or watchOS
|
||||
-----------------------------------------
|
||||
Cross Compiling for iOS, tvOS, visionOS, or watchOS
|
||||
---------------------------------------------------
|
||||
|
||||
For cross-compiling to iOS, tvOS, or watchOS, the :generator:`Xcode`
|
||||
For cross-compiling to iOS, tvOS, visionOS, 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.
|
||||
@@ -591,13 +591,14 @@ a different SDK (e.g. a simulator) can be selected by setting the
|
||||
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
|
||||
======= ================= ==================== ================
|
||||
======== ================= ==================== ================
|
||||
OS CMAKE_SYSTEM_NAME Device SDK (default) Simulator SDK
|
||||
======== ================= ==================== ================
|
||||
iOS iOS iphoneos iphonesimulator
|
||||
tvOS tvOS appletvos appletvsimulator
|
||||
visionOS visionOS xros xrsimulator
|
||||
watchOS watchOS watchos watchsimulator
|
||||
======== ================= ==================== ================
|
||||
|
||||
For example, to create a CMake configuration for iOS, the following
|
||||
command is sufficient:
|
||||
@@ -608,7 +609,7 @@ command is sufficient:
|
||||
|
||||
Variable :variable:`CMAKE_OSX_ARCHITECTURES` can be used to set architectures
|
||||
for both device and simulator. Variable :variable:`CMAKE_OSX_DEPLOYMENT_TARGET`
|
||||
can be used to set an iOS/tvOS/watchOS deployment target.
|
||||
can be used to set an iOS/tvOS/visionOS/watchOS deployment target.
|
||||
|
||||
Next configuration will install fat 5 architectures iOS library
|
||||
and add the ``-miphoneos-version-min=9.3``/``-mios-simulator-version-min=9.3``
|
||||
|
||||
@@ -16,8 +16,8 @@ generator emits the ``EFFECTIVE_PLATFORM_NAME`` variable:
|
||||
- If set to ``ON`` it will always be emitted
|
||||
- If set to ``OFF`` it will never be emitted
|
||||
- If unset (the default) it will only be emitted when the project was
|
||||
configured for an embedded Xcode SDK like iOS, tvOS, watchOS or any
|
||||
of the simulators.
|
||||
configured for an embedded Xcode SDK like iOS, tvOS, visionOS, watchOS
|
||||
or any of the simulators.
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ once per architecture for each source file. Unlike the other generators,
|
||||
it does not generate universal object file binaries.
|
||||
|
||||
A further complication with the :generator:`Xcode` generator is that when
|
||||
targeting device platforms (iOS, tvOS or watchOS), the :generator:`Xcode`
|
||||
targeting device platforms (iOS, tvOS, visionOS or watchOS), the :generator:`Xcode`
|
||||
generator has the ability to use either the device or simulator SDK without
|
||||
needing CMake to be re-run. The SDK can be selected at build time.
|
||||
But since some architectures can be supported by both the device and the
|
||||
|
||||
@@ -63,7 +63,8 @@ File-Based API
|
||||
Platforms
|
||||
---------
|
||||
|
||||
* CMake now supports :ref:`Cross Compiling for iOS, tvOS, or watchOS`
|
||||
* CMake now supports
|
||||
:ref:`Cross Compiling for iOS, tvOS, or watchOS <Cross Compiling for iOS, tvOS, visionOS, or watchOS>`
|
||||
using simple toolchain files.
|
||||
|
||||
Command-Line
|
||||
|
||||
7
Help/release/dev/apple-visionos.rst
Normal file
7
Help/release/dev/apple-visionos.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
apple-visionos
|
||||
--------------
|
||||
|
||||
* CMake learned about Apple visionOS and its `xros` and `xrsimulator` SDKs.
|
||||
Compiling for Apple visionOS can be requested by setting
|
||||
:variable:`CMAKE_SYSTEM_NAME` to ``visionOS``. For more
|
||||
information see :manual:`cmake-toolchains(7)`.
|
||||
@@ -2,4 +2,4 @@ APPLE
|
||||
-----
|
||||
|
||||
Set to ``True`` when the target system is an Apple platform
|
||||
(macOS, iOS, tvOS or watchOS).
|
||||
(macOS, iOS, tvOS, visionOS or watchOS).
|
||||
|
||||
@@ -7,4 +7,4 @@ This variable is used to initialize the :prop_tgt:`MACOSX_BUNDLE` property on
|
||||
all the targets. See that target property for additional information.
|
||||
|
||||
This variable is set to ``ON`` by default if :variable:`CMAKE_SYSTEM_NAME`
|
||||
equals to :ref:`iOS, tvOS or watchOS <Cross Compiling for iOS, tvOS, or watchOS>`.
|
||||
equals to :ref:`iOS, tvOS, visionOS or watchOS <Cross Compiling for iOS, tvOS, visionOS, or watchOS>`.
|
||||
|
||||
@@ -7,6 +7,6 @@ remove it while initializing a cache entry of the same name) unless
|
||||
policy :policy:`CMP0126` is set to ``NEW``.
|
||||
|
||||
Despite the ``OSX`` part in the variable name(s) they apply also to
|
||||
other SDKs than macOS like iOS, tvOS, or watchOS.
|
||||
other SDKs than macOS like iOS, tvOS, visionOS, or watchOS.
|
||||
|
||||
This variable is ignored on platforms other than Apple.
|
||||
|
||||
@@ -608,6 +608,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";")
|
||||
if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]" OR
|
||||
CMAKE_OSX_SYSROOT MATCHES "(^|/)[Xx][Rr]" 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]")
|
||||
|
||||
@@ -21,7 +21,8 @@ set(CMAKE_INCLUDE_FLAG_Swift "-I ")
|
||||
|
||||
# FIXME: Move compiler- and platform-specific flags to the above-included modules.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS"
|
||||
OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS"
|
||||
OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ")
|
||||
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ")
|
||||
@@ -30,7 +31,8 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
|
||||
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS"
|
||||
OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS"
|
||||
OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG_SEP "")
|
||||
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP "")
|
||||
else()
|
||||
|
||||
@@ -25,7 +25,7 @@ unset(LINUX)
|
||||
# It is useful to share the same aforementioned configuration files and
|
||||
# avoids duplicating them in case of tightly related platforms.
|
||||
#
|
||||
# An example are the platforms supported by Xcode (macOS, iOS, tvOS,
|
||||
# An example are the platforms supported by Xcode (macOS, iOS, tvOS, visionOS
|
||||
# and watchOS). For all of those the CMAKE_EFFECTIVE_SYSTEM_NAME is
|
||||
# set to Apple which results in using
|
||||
# Platform/Apple-AppleClang-CXX.cmake for the Apple C++ compiler.
|
||||
|
||||
@@ -22,6 +22,10 @@ macro(__apple_compiler_clang lang)
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtvos-version-min=")
|
||||
elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTVSimulator")
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtvos-simulator-version-min=")
|
||||
elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XROS")
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtargetos=xros")
|
||||
elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XRSimulator")
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtargetos=xros")
|
||||
elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/WatchOS")
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mwatchos-version-min=")
|
||||
elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/WatchSimulator")
|
||||
|
||||
@@ -43,7 +43,7 @@ if(NOT CMAKE_CROSSCOMPILING AND
|
||||
unset(_sysctl_stdout)
|
||||
endif()
|
||||
|
||||
# macOS, iOS, tvOS, and watchOS should lookup compilers from
|
||||
# macOS, iOS, tvOS, visionOS, and watchOS should lookup compilers from
|
||||
# Platform/Apple-${CMAKE_CXX_COMPILER_ID}-<LANG>
|
||||
set(CMAKE_EFFECTIVE_SYSTEM_NAME "Apple")
|
||||
|
||||
@@ -76,6 +76,8 @@ 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 visionOS)
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "xros")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL watchOS)
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "watchos")
|
||||
elseif("${CMAKE_GENERATOR}" MATCHES Xcode
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
if(NOT DEFINED CMAKE_MACOSX_BUNDLE)
|
||||
set(CMAKE_MACOSX_BUNDLE ON)
|
||||
endif()
|
||||
|
||||
1
Modules/Platform/visionOS-Determine-CXX.cmake
Normal file
1
Modules/Platform/visionOS-Determine-CXX.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin-Determine-CXX)
|
||||
7
Modules/Platform/visionOS-Initialize.cmake
Normal file
7
Modules/Platform/visionOS-Initialize.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
include(Platform/Darwin-Initialize)
|
||||
|
||||
if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/XR(OS|Simulator)")
|
||||
message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an visionOS SDK")
|
||||
endif()
|
||||
|
||||
set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
|
||||
1
Modules/Platform/visionOS.cmake
Normal file
1
Modules/Platform/visionOS.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include(Platform/Darwin)
|
||||
@@ -5155,6 +5155,10 @@ std::string cmGlobalXCodeGenerator::GetDeploymentPlatform(const cmMakefile* mf)
|
||||
case cmMakefile::AppleSDK::WatchSimulator:
|
||||
return "WATCHOS_DEPLOYMENT_TARGET";
|
||||
|
||||
case cmMakefile::AppleSDK::XROS:
|
||||
case cmMakefile::AppleSDK::XRSimulator:
|
||||
return "XROS_DEPLOYMENT_TARGET";
|
||||
|
||||
case cmMakefile::AppleSDK::MacOS:
|
||||
default:
|
||||
return "MACOSX_DEPLOYMENT_TARGET";
|
||||
|
||||
@@ -83,6 +83,12 @@ void cmLocalXCodeGenerator::AddGeneratorSpecificInstallSetup(std::ostream& os)
|
||||
case cmMakefile::AppleSDK::WatchSimulator:
|
||||
platformName = "watchsimulator";
|
||||
break;
|
||||
case cmMakefile::AppleSDK::XROS:
|
||||
platformName = "xros";
|
||||
break;
|
||||
case cmMakefile::AppleSDK::XRSimulator:
|
||||
platformName = "xrsimulator";
|
||||
break;
|
||||
case cmMakefile::AppleSDK::MacOS:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2565,6 +2565,8 @@ cmMakefile::AppleSDK cmMakefile::GetAppleSDKType() const
|
||||
{ "iphonesimulator", AppleSDK::IPhoneSimulator },
|
||||
{ "watchos", AppleSDK::WatchOS },
|
||||
{ "watchsimulator", AppleSDK::WatchSimulator },
|
||||
{ "xros", AppleSDK::XROS },
|
||||
{ "xrsimulator", AppleSDK::XRSimulator },
|
||||
};
|
||||
|
||||
for (auto const& entry : sdkDatabase) {
|
||||
|
||||
@@ -561,6 +561,8 @@ public:
|
||||
AppleTVSimulator,
|
||||
WatchOS,
|
||||
WatchSimulator,
|
||||
XROS,
|
||||
XRSimulator,
|
||||
};
|
||||
|
||||
/** What SDK type points CMAKE_OSX_SYSROOT to? */
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
# if __MAC_OS_X_VERSION_MIN_REQUIRED != __MAC_10_11
|
||||
# error macOS deployment version mismatch
|
||||
# endif
|
||||
#elif TARGET_OS_XR
|
||||
# if __XR_OS_VERSION_MIN_REQUIRED != __XROS_1_0
|
||||
# error visionOS deployment version mismatch
|
||||
# endif
|
||||
#elif TARGET_OS_IOS
|
||||
# if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_9_1
|
||||
# error iOS deployment version mismatch
|
||||
|
||||
@@ -7,6 +7,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "visionOS")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "1.0")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
|
||||
|
||||
@@ -93,6 +93,25 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
endif()
|
||||
|
||||
if(NOT XCODE_VERSION VERSION_LESS 15)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesVisionOS-build)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_OPTIONS
|
||||
"-DCMAKE_SYSTEM_NAME=visionOS"
|
||||
"-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
|
||||
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||
|
||||
run_cmake(XcodeBundles)
|
||||
run_cmake_command(XcodeBundles-build-visionOS ${CMAKE_COMMAND} --build .)
|
||||
run_cmake_command(XcodeBundles-install-visionOS ${CMAKE_COMMAND} --build . --target install)
|
||||
|
||||
unset(RunCMake_TEST_BINARY_DIR)
|
||||
unset(RunCMake_TEST_NO_CLEAN)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
endif()
|
||||
|
||||
if(NOT XCODE_VERSION VERSION_LESS 7)
|
||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake")
|
||||
run_cmake(XcodeTbdStub)
|
||||
@@ -242,6 +261,10 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
|
||||
deployment_target_test(tvOS appletvsimulator)
|
||||
deployment_target_test(watchOS watchos)
|
||||
deployment_target_test(watchOS watchsimulator)
|
||||
if(XCODE_VERSION VERSION_GREATER_EQUAL 15)
|
||||
deployment_target_test(visionOS xros)
|
||||
deployment_target_test(visionOS xrsimulator)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
|
||||
|
||||
@@ -9,7 +9,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
|
||||
|
||||
@@ -126,7 +126,7 @@ if ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
|
||||
((DEFINED MSVC_VERSION AND MSVC_VERSION GREATER "1900") OR (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC")))
|
||||
OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND
|
||||
(NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION GREATER "5.9"))
|
||||
OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS|Linux|BSD|MSYS|CYGWIN")
|
||||
OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|visionOS|watchOS|Linux|BSD|MSYS|CYGWIN")
|
||||
run_cmake(feature-WHOLE_ARCHIVE)
|
||||
run_cmake_target(feature-WHOLE_ARCHIVE link-exe main)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user