diff options
author | Brad King <brad.king@kitware.com> | 2024-02-12 15:45:03 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-02-12 15:45:32 (GMT) |
commit | b3812c66288c673b9ea4908334888e3806b17a62 (patch) | |
tree | c58cb9287994b3bc1a5b00722edabf275ea18aea | |
parent | c673511263822c688fa302120a29e1e0cf812c0b (diff) | |
parent | 5b5acb557a03b77a3500b467b4c477ad4bfe56b5 (diff) | |
download | CMake-b3812c66288c673b9ea4908334888e3806b17a62.zip CMake-b3812c66288c673b9ea4908334888e3806b17a62.tar.gz CMake-b3812c66288c673b9ea4908334888e3806b17a62.tar.bz2 |
Merge topic 'visionOS' into release-3.29
5b5acb557a Tests: Enable RunCMake.CMakePackage visionOS cases with Xcode 15.2
871a4c5aac Merge branch 'backport-3.28-visionOS' into visionOS
22eb1b6d67 Tests: Enable visionOS tests with Xcode 15.2
f6fa34839c Tests: Update RunCMake.XcodeProject-Device for visionOS in Xcode 15.1 beta
40be88a92e visionOS: Update deployment-target flag for Xcode 15.1 beta
3ece4553c2 cmLocalGenerator: Avoid unnecessary lookup without a deployment target
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Volodymyr B. <v.boichentsov@elsevier.com>
Merge-request: !9239
-rw-r--r-- | Modules/Platform/Apple-Clang.cmake | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 51 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePackage/RunCMakeTest.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePackage/apple-export-common.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/XcFramework/RunCMakeTest.cmake | 35 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c | 4 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake | 46 |
7 files changed, 90 insertions, 63 deletions
diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake index 7986a37..bd5ba9a 100644 --- a/Modules/Platform/Apple-Clang.cmake +++ b/Modules/Platform/Apple-Clang.cmake @@ -35,10 +35,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 "/XROS") + set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "--target=<ARCH>-apple-xros<VERSION_MIN>") elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XRSimulator") - set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtargetos=xros") + set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "--target=<ARCH>-apple-xros<VERSION_MIN>-simulator") 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/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e7fa717..0e539fe 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2011,14 +2011,49 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, cmValue deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); - std::string deploymentTargetFlagVar = - "CMAKE_" + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; - cmValue deploymentTargetFlag = - this->Makefile->GetDefinition(deploymentTargetFlagVar); - if (cmNonempty(deploymentTargetFlag) && cmNonempty(deploymentTarget)) { - flags += " "; - flags += *deploymentTargetFlag; - flags += *deploymentTarget; + if (cmNonempty(deploymentTarget)) { + std::string deploymentTargetFlagVar = + "CMAKE_" + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; + cmValue deploymentTargetFlag = + this->Makefile->GetDefinition(deploymentTargetFlagVar); + if (cmNonempty(deploymentTargetFlag) && + // CMAKE_<LANG>_COMPILER_TARGET overrides a --target= for + // CMAKE_OSX_DEPLOYMENT_TARGET, e.g., for visionOS. + (!cmHasLiteralPrefix(*deploymentTarget, "--target=") || + this->Makefile + ->GetDefinition(cmStrCat("CMAKE_", lang, "_COMPILER_TARGET")) + .IsEmpty())) { + std::string flag = *deploymentTargetFlag; + + // Add the deployment target architecture to the flag, if needed. + static const std::string kARCH = "<ARCH>"; + std::string::size_type archPos = flag.find(kARCH); + if (archPos != std::string::npos) { + // This placeholder is meant for visionOS, so default to arm64 + // unless only non-arm64 archs are given. + std::string const arch = + (archs.empty() || cm::contains(archs, "arm64")) ? "arm64" + : archs[0]; + // Replace the placeholder with its value. + flag = cmStrCat(flag.substr(0, archPos), arch, + flag.substr(archPos + kARCH.size())); + } + + // Add the deployment target version to the flag. + static const std::string kVERSION_MIN = "<VERSION_MIN>"; + std::string::size_type verPos = flag.find(kVERSION_MIN); + if (verPos != std::string::npos) { + // Replace the placeholder with its value. + flag = cmStrCat(flag.substr(0, verPos), *deploymentTarget, + flag.substr(verPos + kVERSION_MIN.size())); + } else { + // There is no placeholder, so append the value. + flag = cmStrCat(flag, *deploymentTarget); + } + + flags += " "; + flags += flag; + } } } } diff --git a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake index 4145ccc..32fc7fb 100644 --- a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake @@ -64,10 +64,9 @@ if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") set(watch_archs "armv7k") endif() - #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. - #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) - # set(enable_visionos 1) - #endif() + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + set(enable_visionos 1) + endif() apple_export(macos Darwin "${macos_archs}" macosx) apple_export(ios iOS "arm64" iphoneos) diff --git a/Tests/RunCMake/CMakePackage/apple-export-common.cmake b/Tests/RunCMake/CMakePackage/apple-export-common.cmake index 15e98eb..2c79b7b 100644 --- a/Tests/RunCMake/CMakePackage/apple-export-common.cmake +++ b/Tests/RunCMake/CMakePackage/apple-export-common.cmake @@ -21,8 +21,8 @@ generate_apple_platform_selection_file(mylib-config-install.cmake IOS_SIMULATOR_INCLUDE_FILE ${IOS_SIMULATOR_INCLUDE_FILE} TVOS_INCLUDE_FILE lib/tvos/cmake/mylib/mylib-targets.cmake TVOS_SIMULATOR_INCLUDE_FILE lib/tvos-simulator/cmake/mylib/mylib-targets.cmake - VISIONOS_INCLUDE_FILE lib/watchos/cmake/mylib/mylib-targets.cmake - VISIONOS_SIMULATOR_INCLUDE_FILE lib/watchos-simulator/cmake/mylib/mylib-targets.cmake + VISIONOS_INCLUDE_FILE lib/visionos/cmake/mylib/mylib-targets.cmake + VISIONOS_SIMULATOR_INCLUDE_FILE lib/visionos-simulator/cmake/mylib/mylib-targets.cmake WATCHOS_INCLUDE_FILE lib/watchos/cmake/mylib/mylib-targets.cmake WATCHOS_SIMULATOR_INCLUDE_FILE lib/watchos-simulator/cmake/mylib/mylib-targets.cmake ) diff --git a/Tests/RunCMake/XcFramework/RunCMakeTest.cmake b/Tests/RunCMake/XcFramework/RunCMakeTest.cmake index fad088f..0d181ca 100644 --- a/Tests/RunCMake/XcFramework/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcFramework/RunCMakeTest.cmake @@ -14,17 +14,15 @@ function(create_libraries type) create_library(${type} ios iOS "arm64" iphoneos) create_library(${type} tvos tvOS "arm64" appletvos) create_library(${type} watchos watchOS "armv7k\\\\;arm64_32" watchos) - #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. - #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) - # create_library(${type} visionos visionOS "arm64" xros) - #endif() + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + create_library(${type} visionos visionOS "arm64" xros) + endif() create_library(${type} ios-simulator iOS "${macos_archs_2}" iphonesimulator) create_library(${type} tvos-simulator tvOS "${macos_archs_2}" appletvsimulator) create_library(${type} watchos-simulator watchOS "${watch_sim_archs_2}" watchsimulator) - #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. - #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) - # create_library(${type} visionos-simulator visionOS "${macos_archs_2}" xrsimulator) - #endif() + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + create_library(${type} visionos-simulator visionOS "${macos_archs_2}" xrsimulator) + endif() endfunction() function(create_xcframework name type platforms) @@ -62,24 +60,21 @@ function(create_executables name type) create_executable(${name}-ios ${type} iOS "arm64" iphoneos) create_executable(${name}-tvos ${type} tvOS "arm64" appletvos) create_executable(${name}-watchos ${type} watchOS "armv7k\\\\;arm64_32" watchos) - #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. - #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) - # create_executable(${name}-visionos ${type} visionOS "arm64" xros) - #endif() + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + create_executable(${name}-visionos ${type} visionOS "arm64" xros) + endif() create_executable(${name}-ios-simulator ${type} iOS "${macos_archs_2}" iphonesimulator) create_executable(${name}-tvos-simulator ${type} tvOS "${macos_archs_2}" appletvsimulator) create_executable(${name}-watchos-simulator ${type} watchOS "${watch_sim_archs_2}" watchsimulator) - #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. - #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) - # create_executable(${name}-visionos-simulator ${type} visionOS "${macos_archs_2}" xrsimulator) - #endif() + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + create_executable(${name}-visionos-simulator ${type} visionOS "${macos_archs_2}" xrsimulator) + endif() endfunction() set(xcframework_platforms macos ios tvos watchos ios-simulator tvos-simulator watchos-simulator) -#FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. -#if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) -# list(APPEND xcframework_platforms visionos visionos-simulator) -#endif() +if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + list(APPEND xcframework_platforms visionos visionos-simulator) +endif() if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12) set(macos_archs_1 "x86_64\\;arm64") set(macos_archs_2 "x86_64\\\\;arm64") diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c index 76ca54e..630f13a 100644 --- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c @@ -5,8 +5,8 @@ # 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 +#elif TARGET_OS_VISION +# if __VISION_OS_VERSION_MIN_REQUIRED != __VISIONOS_1_0 # error visionOS deployment version mismatch # endif #elif TARGET_OS_IOS diff --git a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake index e4dbb90..b61b7fc 100644 --- a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake @@ -93,25 +93,24 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) unset(RunCMake_TEST_OPTIONS) endif() -#FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. -#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 15.2) + 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") @@ -262,11 +261,10 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) deployment_target_test(tvOS appletvsimulator) deployment_target_test(watchOS watchos) deployment_target_test(watchOS watchsimulator) - #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. - #if(XCODE_VERSION VERSION_GREATER_EQUAL 15) - # deployment_target_test(visionOS xros) - # deployment_target_test(visionOS xrsimulator) - #endif() + if(XCODE_VERSION VERSION_GREATER_EQUAL 15.2) + deployment_target_test(visionOS xros) + deployment_target_test(visionOS xrsimulator) + endif() endif() if(XCODE_VERSION VERSION_GREATER_EQUAL 8) |