CMake: Show the active Apple SDK path when configuring qtbase

Starting with CMake 4.0, CMake doesn't initialize the
CMAKE_OSX_SYSROOT variable with any value when running on a macOS
host and no explicit CMAKE_OSX_SYSROOT or CMAKE_SYSTEM_NAME is set.

CMake expects the platform compiler wrapper /usr/bin/c++ to pass an
appropriate -isysroot flag to the underlying compiler, without CMake
explicitly setting one.

This mostly works, but the configure output will not show anymore the
active sysroot path.

Query the active path from xcrun, and display it in the configure
output.

Pick-to: 6.8
Task-number: QTBUG-135621
Change-Id: Ic9b9a43e25bb88bb83165dce52356c77ea8fffe1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit ab7eb492cba64fe985ea80b2f0be22c1c18f3c5e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2025-04-08 17:49:17 +02:00
parent 3ce44b88e2
commit 189d5ebbda
3 changed files with 23 additions and 0 deletions

View File

@ -274,6 +274,9 @@ function(qt_auto_detect_apple)
endif()
endif()
_qt_internal_get_apple_sdk_path(apple_sdk_path)
set(QT_APPLE_SDK_PATH "${apple_sdk_path}" CACHE STRING "Darwin SDK path.")
_qt_internal_get_apple_sdk_version(apple_sdk_version)
set(QT_MAC_SDK_VERSION "${apple_sdk_version}" CACHE STRING "Darwin SDK version.")

View File

@ -274,6 +274,7 @@ function(qt_internal_print_cmake_darwin_info)
endif()
message(STATUS "CMAKE_OSX_ARCHITECTURES: \"${CMAKE_OSX_ARCHITECTURES}\"${default_osx_arch}")
message(STATUS "CMAKE_OSX_SYSROOT: \"$CACHE{CMAKE_OSX_SYSROOT}\" / \"${CMAKE_OSX_SYSROOT}\"")
message(STATUS "QT_APPLE_SDK_PATH: \"${QT_APPLE_SDK_PATH}\"")
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: \"${CMAKE_OSX_DEPLOYMENT_TARGET}\"")
message(STATUS "QT_MAC_SDK_VERSION: \"${QT_MAC_SDK_VERSION}\"")
message(STATUS "QT_MAC_XCODE_VERSION: \"${QT_MAC_XCODE_VERSION}\"")

View File

@ -859,6 +859,25 @@ function(_qt_internal_execute_xcrun out_var)
set(${out_var} "${output}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_apple_sdk_path out_var)
set(sdk_path "")
if(APPLE)
_qt_internal_get_apple_sdk_name(sdk_name)
_qt_internal_execute_xcrun(sdk_path
XCRUN_ARGS --sdk ${sdk_name} --show-sdk-path
OUT_ERROR_VAR xcrun_error
)
if(NOT sdk_path)
message(FATAL_ERROR
"Can't determine darwin ${sdk_name} SDK path. Error: ${xcrun_error}")
endif()
string(STRIP "${sdk_path}" sdk_path)
endif()
set(${out_var} "${sdk_path}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_apple_sdk_version out_var)
set(sdk_version "")
if(APPLE)