CMake: Improve Apple SDK name and path reporting

If CMAKE_OSX_SYSROOT or QT_APPLE_SDK was set, we still reported the
default platform sdk path, rather than taking into account the set
value.

Improve the reporting by considering these values.

The implementation is incomplete because we don't handle explicit sdk
paths, but this is not critical for the current use cases, because the
value of the function is only used for reporting purposes.

Amends ab7eb492cba64fe985ea80b2f0be22c1c18f3c5e

Pick-to: 6.8
Change-Id: Ic69aec3641d435736018c96f72ba7f75a0f74508
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 747741119ab5fa0bdcdb923e9088ffe287875ebf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 98ac864cabf6cdbca6691446e8b6fd49659f15d1)
This commit is contained in:
Alexandru Croitor 2025-06-02 10:57:09 +02:00 committed by Qt Cherry-pick Bot
parent f5f66610b3
commit f09e396732

View File

@ -811,19 +811,50 @@ endif()")
set(${out_var} "${assignments}" PARENT_SCOPE)
endfunction()
# Returns the active apple sdk name that was either explicitly set by the user via QT_APPLE_SDK or
# or CMAKE_OSX_SYSROOT, or return the default approximated value, based on what CMake does
# internally.
#
# TODO: Handle case when CMAKE_OSX_SYSROOT is set to an sdk path, from which we need to retrieve the
# sdk name.
function(_qt_internal_get_apple_sdk_name out_var)
set(sdk_name "")
if(APPLE)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(sdk_name "iphoneos")
elseif(CMAKE_SYSTEM_NAME STREQUAL visionOS)
set(sdk_name "xros")
if(NOT APPLE)
set(${out_var} "" PARENT_SCOPE)
return()
endif()
# If CMake or the user has set an explicit sdk name, consider it.
if(QT_APPLE_SDK)
set(explicit_sdk_name "${QT_APPLE_SDK}")
elseif(CMAKE_OSX_SYSROOT)
set(explicit_sdk_name "${CMAKE_OSX_SYSROOT}")
else()
# Default to macOS
set(sdk_name "macosx")
set(explicit_sdk_name "")
endif()
set(output_sdk_name "")
# Detect (or check if already set) that the sdk name is one that Qt knows about.
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
if(explicit_sdk_name STREQUAL "iphoneos" OR explicit_sdk_name STREQUAL "iphonesimulator")
set(output_sdk_name "${explicit_sdk_name}")
else()
# Default case.
set(output_sdk_name "iphoneos")
endif()
set(${out_var} "${sdk_name}" PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME STREQUAL visionOS)
if(explicit_sdk_name STREQUAL "xros" OR explicit_sdk_name STREQUAL "xrsimulator")
set(output_sdk_name "${explicit_sdk_name}")
else()
# Default case.
set(output_sdk_name "xros")
endif()
else()
# Default case.
set(output_sdk_name "macosx")
endif()
set(${out_var} "${output_sdk_name}" PARENT_SCOPE)
endfunction()
function(_qt_internal_execute_xcrun out_var)