From 25977e177be14189796630fac9f1d6ecdccc56bd Mon Sep 17 00:00:00 2001
From: Gregor Jasny <gjasny@googlemail.com>
Date: Thu, 22 Jun 2023 11:57:36 +0200
Subject: apple: add preliminary visionOS support

---
 Help/manual/cmake-toolchains.7.rst                 | 25 +++++++++++-----------
 .../XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst         |  4 ++--
 Help/prop_tgt/IMPORTED_OBJECTS.rst                 |  2 +-
 Help/release/3.14.rst                              |  3 ++-
 Help/release/dev/apple-visionos.rst                |  7 ++++++
 Help/variable/APPLE.rst                            |  2 +-
 Help/variable/CMAKE_MACOSX_BUNDLE.rst              |  2 +-
 Help/variable/CMAKE_OSX_VARIABLE.txt               |  2 +-
 Modules/CMakeDetermineCompilerId.cmake             |  1 +
 Modules/CMakeSwiftInformation.cmake                |  6 ++++--
 Modules/CMakeSystemSpecificInitialize.cmake        |  2 +-
 Modules/Platform/Apple-Clang.cmake                 |  4 ++++
 Modules/Platform/Darwin-Initialize.cmake           |  4 +++-
 Modules/Platform/Darwin.cmake                      |  2 +-
 Modules/Platform/visionOS-Determine-CXX.cmake      |  1 +
 Modules/Platform/visionOS-Initialize.cmake         |  7 ++++++
 Modules/Platform/visionOS.cmake                    |  1 +
 Source/cmGlobalXCodeGenerator.cxx                  |  4 ++++
 Source/cmLocalXCodeGenerator.cxx                   |  6 ++++++
 Source/cmMakefile.cxx                              |  2 ++
 Source/cmMakefile.h                                |  2 ++
 .../XcodeProject-Device/DeploymentTarget.c         |  4 ++++
 .../XcodeProject-Device/DeploymentTarget.cmake     |  6 ++++++
 .../XcodeProject-Device/RunCMakeTest.cmake         | 23 ++++++++++++++++++++
 .../XcodeProject-Device/XcodeBundles.cmake         |  2 +-
 .../RunCMakeTest.cmake                             |  2 +-
 26 files changed, 100 insertions(+), 26 deletions(-)
 create mode 100644 Help/release/dev/apple-visionos.rst
 create mode 100644 Modules/Platform/visionOS-Determine-CXX.cmake
 create mode 100644 Modules/Platform/visionOS-Initialize.cmake
 create mode 100644 Modules/Platform/visionOS.cmake

diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index a831fa6..e32bd29 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -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``
diff --git a/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst b/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst
index 392b704..6794a26 100644
--- a/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst
+++ b/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst
@@ -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::
 
diff --git a/Help/prop_tgt/IMPORTED_OBJECTS.rst b/Help/prop_tgt/IMPORTED_OBJECTS.rst
index d71c219..9aacea7 100644
--- a/Help/prop_tgt/IMPORTED_OBJECTS.rst
+++ b/Help/prop_tgt/IMPORTED_OBJECTS.rst
@@ -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
diff --git a/Help/release/3.14.rst b/Help/release/3.14.rst
index 8a9738c..5fedf7d 100644
--- a/Help/release/3.14.rst
+++ b/Help/release/3.14.rst
@@ -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
diff --git a/Help/release/dev/apple-visionos.rst b/Help/release/dev/apple-visionos.rst
new file mode 100644
index 0000000..db76248
--- /dev/null
+++ b/Help/release/dev/apple-visionos.rst
@@ -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)`.
diff --git a/Help/variable/APPLE.rst b/Help/variable/APPLE.rst
index 810d5fc..e799397 100644
--- a/Help/variable/APPLE.rst
+++ b/Help/variable/APPLE.rst
@@ -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).
diff --git a/Help/variable/CMAKE_MACOSX_BUNDLE.rst b/Help/variable/CMAKE_MACOSX_BUNDLE.rst
index 43ddff5..483c5b3 100644
--- a/Help/variable/CMAKE_MACOSX_BUNDLE.rst
+++ b/Help/variable/CMAKE_MACOSX_BUNDLE.rst
@@ -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>`.
diff --git a/Help/variable/CMAKE_OSX_VARIABLE.txt b/Help/variable/CMAKE_OSX_VARIABLE.txt
index 5670980..962fcd3 100644
--- a/Help/variable/CMAKE_OSX_VARIABLE.txt
+++ b/Help/variable/CMAKE_OSX_VARIABLE.txt
@@ -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.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 6c49096..4db9aa8 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -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]")
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index 777c680..1c6f0df 100644
--- a/Modules/CMakeSwiftInformation.cmake
+++ b/Modules/CMakeSwiftInformation.cmake
@@ -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()
diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake
index e87d868..ee8cb86 100644
--- a/Modules/CMakeSystemSpecificInitialize.cmake
+++ b/Modules/CMakeSystemSpecificInitialize.cmake
@@ -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.
diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake
index 0681bfb..4d7546a 100644
--- a/Modules/Platform/Apple-Clang.cmake
+++ b/Modules/Platform/Apple-Clang.cmake
@@ -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")
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index e253392..8d5bf8c 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -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
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 48a9065..d614182 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -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()
diff --git a/Modules/Platform/visionOS-Determine-CXX.cmake b/Modules/Platform/visionOS-Determine-CXX.cmake
new file mode 100644
index 0000000..ac80fa6
--- /dev/null
+++ b/Modules/Platform/visionOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/visionOS-Initialize.cmake b/Modules/Platform/visionOS-Initialize.cmake
new file mode 100644
index 0000000..e8431bc
--- /dev/null
+++ b/Modules/Platform/visionOS-Initialize.cmake
@@ -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)
diff --git a/Modules/Platform/visionOS.cmake b/Modules/Platform/visionOS.cmake
new file mode 100644
index 0000000..850ddc2
--- /dev/null
+++ b/Modules/Platform/visionOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index fd58f75..0472631 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -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";
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 759ee7b..eb05424 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -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;
     }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5890819..e1841b6 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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) {
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 7005942..79a98cd 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -561,6 +561,8 @@ public:
     AppleTVSimulator,
     WatchOS,
     WatchSimulator,
+    XROS,
+    XRSimulator,
   };
 
   /** What SDK type points CMAKE_OSX_SYSROOT to? */
diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c
index 5e0f40f..c00fce7 100644
--- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c
+++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c
@@ -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
diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake
index 234ceef..80e3877 100644
--- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake
+++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake
@@ -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")
diff --git a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake
index e2ed045..b3ab624 100644
--- a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake
index a9fafd2..376a7fc 100644
--- a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake
+++ b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake
@@ -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 "")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
index 9b6581c..8e4745a 100644
--- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
@@ -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()
-- 
cgit v0.12