cmake: Rename QT_UIKIT_SDK to QT_APPLE_SDK

The SDK is relevant for all Apple systems, including macOS, iOS, tvOS,
watchOS, and visionOS.

We still pick up -DQT_UIKIT_SDK for iOS for compatibility.

[ChangeLog][CMake] The -sdk configure argument now maps
to the QT_APPLE_SDK CMake variable. QT_UIKIT_SDK is still
supported for iOS builds for compatibility.

Change-Id: I983a2f23c2414eb73cd35bb83738088defb45cbd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tor Arne Vestbø 2024-03-18 11:58:22 +01:00
parent 09705c74b2
commit d04cf2c58b
12 changed files with 35 additions and 30 deletions

View File

@ -181,10 +181,15 @@ function(qt_auto_detect_ios)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
message(STATUS "Using internal CMake ${CMAKE_SYSTEM_NAME} toolchain file.")
# The QT_UIKIT_SDK check simulates the input.sdk condition for simulator_and_device in
# Pass on QT_UIKIT_SDK for compatibility
if(QT_UIKIT_SDK AND NOT QT_APPLE_SDK)
set(QT_APPLE_SDK "${QT_UIKIT_SDK}" CACHE STRING "")
endif()
# The QT_APPLE_SDK check simulates the input.sdk condition for simulator_and_device in
# configure.json.
# If the variable is explicitly provided, assume simulator_and_device to be off.
if(QT_UIKIT_SDK)
if(QT_APPLE_SDK)
set(simulator_and_device OFF)
else()
# Default to simulator_and_device when an explicit sdk is not requested.
@ -199,24 +204,24 @@ function(qt_auto_detect_ios)
# architectures, otherwise compilation fails with unknown defines.
if(simulator_and_device)
set(osx_architectures "arm64;x86_64")
elseif(QT_UIKIT_SDK STREQUAL "iphoneos")
elseif(QT_APPLE_SDK STREQUAL "iphoneos")
set(osx_architectures "arm64")
elseif(QT_UIKIT_SDK STREQUAL "iphonesimulator")
elseif(QT_APPLE_SDK STREQUAL "iphonesimulator")
set(osx_architectures "x86_64")
else()
if(NOT DEFINED QT_UIKIT_SDK)
message(FATAL_ERROR "Please provide a value for -DQT_UIKIT_SDK."
if(NOT DEFINED QT_APPLE_SDK)
message(FATAL_ERROR "Please provide a value for -DQT_APPLE_SDK."
" Possible values: iphoneos, iphonesimulator.")
else()
message(FATAL_ERROR
"Unknown SDK argument given to QT_UIKIT_SDK: ${QT_UIKIT_SDK}.")
"Unknown SDK argument given to QT_APPLE_SDK: ${QT_APPLE_SDK}.")
endif()
endif()
# For non simulator_and_device builds, we need to explicitly set the SYSROOT aka the sdk
# value.
if(QT_UIKIT_SDK)
set(CMAKE_OSX_SYSROOT "${QT_UIKIT_SDK}" CACHE STRING "")
if(QT_APPLE_SDK)
set(CMAKE_OSX_SYSROOT "${QT_APPLE_SDK}" CACHE STRING "")
endif()
set(CMAKE_OSX_ARCHITECTURES "${osx_architectures}" CACHE STRING "")

View File

@ -203,8 +203,8 @@ function(qt_internal_print_cmake_darwin_info)
if(DEFINED CACHE{QT_IS_MACOS_UNIVERSAL})
message(STATUS "QT_IS_MACOS_UNIVERSAL: \"${QT_IS_MACOS_UNIVERSAL}\"")
endif()
if(QT_UIKIT_SDK)
message(STATUS "QT_UIKIT_SDK: \"${QT_UIKIT_SDK}\"")
if(QT_APPLE_SDK)
message(STATUS "QT_APPLE_SDK: \"${QT_APPLE_SDK}\"")
endif()
qt_internal_get_first_osx_arch(osx_first_arch)
if(osx_first_arch)

View File

@ -1192,8 +1192,8 @@ function(qt_get_platform_try_compile_vars out_var)
if(UIKIT)
# Specify the sysroot, but only if not doing a simulator_and_device build.
# So keep the sysroot empty for simulator_and_device builds.
if(QT_UIKIT_SDK)
list(APPEND flags_cmd_line "-DCMAKE_OSX_SYSROOT:STRING=${QT_UIKIT_SDK}")
if(QT_APPLE_SDK)
list(APPEND flags_cmd_line "-DCMAKE_OSX_SYSROOT:STRING=${QT_APPLE_SDK}")
endif()
endif()
if(QT_NO_USE_FIND_PACKAGE_SYSTEM_ENVIRONMENT_PATH)

View File

@ -630,9 +630,9 @@ set(__qt_internal_initial_qt_cmake_build_type \"${CMAKE_BUILD_TYPE}\")
"set(QT_IS_MACOS_UNIVERSAL \"${QT_IS_MACOS_UNIVERSAL}\" CACHE BOOL \"\")\n")
endif()
if(DEFINED QT_UIKIT_SDK)
if(DEFINED QT_APPLE_SDK)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
"set(QT_UIKIT_SDK \"${QT_UIKIT_SDK}\" CACHE BOOL \"\")\n")
"set(QT_APPLE_SDK \"${QT_APPLE_SDK}\" CACHE BOOL \"\")\n")
endif()
if(QT_FORCE_FIND_TOOLS)

View File

@ -873,8 +873,8 @@ function(qt_generate_global_device_pri_file)
endif()
endif()
if(QT_UIKIT_SDK)
string(APPEND content "QMAKE_MAC_SDK = ${QT_UIKIT_SDK}\n")
if(QT_APPLE_SDK)
string(APPEND content "QMAKE_MAC_SDK = ${QT_APPLE_SDK}\n")
endif()
set(gcc_machine_dump "")

View File

@ -924,8 +924,8 @@ endif()
translate_string_input(android-javac-source QT_ANDROID_JAVAC_SOURCE)
translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET)
# FIXME: config_help.txt says -sdk should apply to macOS as well.
translate_string_input(sdk QT_UIKIT_SDK)
translate_string_input(sdk QT_APPLE_SDK)
if(DEFINED INPUT_sdk OR (DEFINED INPUT_xplatform AND INPUT_xplatform STREQUAL "macx-ios-clang")
OR (DEFINED INPUT_platform AND INPUT_platform STREQUAL "macx-ios-clang"))
push("-DCMAKE_SYSTEM_NAME=iOS")

View File

@ -157,12 +157,12 @@ endif()")
list(LENGTH CMAKE_OSX_ARCHITECTURES _qt_osx_architectures_count)
if(CMAKE_OSX_SYSROOT AND NOT _qt_osx_architectures_count GREATER 1 AND UIKIT)
list(APPEND init_platform "
set(__qt_uikit_sdk \"${QT_UIKIT_SDK}\")
set(__qt_apple_sdk \"${QT_APPLE_SDK}\")
set(__qt_initial_cmake_osx_sysroot \"${CMAKE_OSX_SYSROOT}\")
if(NOT DEFINED CMAKE_OSX_SYSROOT AND EXISTS \"\${__qt_initial_cmake_osx_sysroot}\")
set(CMAKE_OSX_SYSROOT \"\${__qt_initial_cmake_osx_sysroot}\" CACHE PATH \"\")
elseif(NOT DEFINED CMAKE_OSX_SYSROOT AND NOT QT_NO_SET_OSX_SYSROOT)
set(CMAKE_OSX_SYSROOT \"\${__qt_uikit_sdk}\" CACHE PATH \"\")
set(CMAKE_OSX_SYSROOT \"\${__qt_apple_sdk}\" CACHE PATH \"\")
endif()")
endif()
@ -218,7 +218,7 @@ endif()")
qt_internal_get_first_osx_arch(osx_first_arch)
list(APPEND init_platform
"if((NOT CMAKE_GENERATOR STREQUAL \"Xcode\" AND NOT __qt_toolchain_building_qt_repo)
OR (CMAKE_GENERATOR STREQUAL \"Xcode\" AND __qt_uikit_sdk AND NOT QT_NO_SET_OSX_ARCHITECTURES))")
OR (CMAKE_GENERATOR STREQUAL \"Xcode\" AND __qt_apple_sdk AND NOT QT_NO_SET_OSX_ARCHITECTURES))")
list(APPEND init_platform
" set(CMAKE_OSX_ARCHITECTURES \"${osx_first_arch}\" CACHE STRING \"\")")
list(APPEND init_platform "endif()")

View File

@ -200,13 +200,13 @@ In order to cross-compile Qt to iOS, you need a host macOS build.
When running cmake in qtbase, pass
``-DCMAKE_SYSTEM_NAME=iOS -DQT_HOST_PATH=/path/to/your/host/build -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH``
If you don't supply the configuration argument ``-DQT_UIKIT_SDK=...``, CMake will build a
If you don't supply the configuration argument ``-DQT_APPLE_SDK=...``, CMake will build a
multi-arch simulator_and_device iOS build.
To target another SDK / device type, use one of the following values:
* iphonesimulator: ``-DQT_UIKIT_SDK=iphonesimulator``
* iphoneos: ``-DQT_UIKIT_SDK=iphoneos``
* iphonesimulator: ``-DQT_APPLE_SDK=iphonesimulator``
* iphoneos: ``-DQT_APPLE_SDK=iphoneos``
Depending on what value you pass to ``-DQT_UIKIT_SDK=`` a list of target architectures is chosen
Depending on what value you pass to ``-DQT_APPLE_SDK=`` a list of target architectures is chosen
by default:
* iphonesimulator: ``x86_64``
* iphoneos: ``arm64``

View File

@ -83,7 +83,7 @@ The following table describes the mapping of configure options to CMake argument
| -I <string> | -DQT_EXTRA_INCLUDEPATHS=<string1>;<string2> | |
| -L <string> | -DQT_EXTRA_LIBDIRS=<string1>;<string2> | |
| -F <string> | -DQT_EXTRA_FRAMEWORKPATHS=<string1>;<string2> | |
| -sdk <sdk> | -DQT_UIKIT_SDK=<value> | Should be provided a value like 'iphoneos' or 'iphonesimulator' |
| -sdk <sdk> | -DQT_APPLE_SDK=<value> | Should be provided a value like 'iphoneos' or 'iphonesimulator' |
| | | If no value is provided, a simulator_and_device build is |
| | | assumed. |
| -android-sdk <path> | -DANDROID_SDK_ROOT=<path> | |

View File

@ -542,7 +542,7 @@ if(APPLE)
endif()
qt_feature("simulator_and_device" PUBLIC
LABEL "Build for both simulator and device"
CONDITION UIKIT AND NOT QT_UIKIT_SDK
CONDITION UIKIT AND NOT QT_APPLE_SDK
)
qt_feature_config("simulator_and_device" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("rpath" PUBLIC

View File

@ -384,7 +384,7 @@ macro(_qt_internal_test_expect_pass _dir)
endif()
if(build_environment STREQUAL "ci"
AND osx_arch_count GREATER_EQUAL 2
AND NOT QT_UIKIT_SDK
AND NOT QT_APPLE_SDK
AND NOT QT_NO_IOS_BUILD_ADJUSTMENT_IN_CI)
list(APPEND additional_configure_args
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_SYSROOT=iphonesimulator)

View File

@ -909,7 +909,7 @@ endif()""",
"condition": "__qt_ltcg_detected",
},
"msvc_mp": None,
"simulator_and_device": {"condition": "UIKIT AND NOT QT_UIKIT_SDK"},
"simulator_and_device": {"condition": "UIKIT AND NOT QT_APPLE_SDK"},
"pkg-config": {"condition": "PKG_CONFIG_FOUND"},
"precompile_header": {"condition": "BUILD_WITH_PCH"},
"profile": None,