mirror of https://github.com/qt/qtbase.git
cmake: Persist macOS SDK name, to work around CMake 4.x
CMake 4 stopped passing explicit toolchain and SDK paths, which results in lots of sharp corners. For example, with xcode-select pointing to /Applications/Xcode.app but with Xcode command line tools installed, CMake will build with /usr/bin/c++, which xcrun resolves to the Xcode toolchain, but as CMake doesn't pass a sysroot, it ends up using the command line tools SDK. This is bad and surprising when the selected Xcode version's SDKs doesn't match the command line tools. CMake 4.0.2 was supposed to fix this, but it seemingly doesn't work. As a workaround, set CMAKE_OSX_SYSROOT for macOS as well, which triggers CMake or xcrun to pass a sysroot, giving us what we want. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ia6d051477a48c4c8e5e90feae67cc8d2734d8e1b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
1e367f2f8c
commit
e462567183
|
@ -248,6 +248,11 @@ function(qt_auto_detect_apple)
|
|||
|
||||
if(QT_APPLE_SDK)
|
||||
set(CMAKE_OSX_SYSROOT "${QT_APPLE_SDK}" CACHE STRING "")
|
||||
elseif(NOT CMAKE_SYSTEM_NAME)
|
||||
# Persist SDK name for macOS builds, since CMake 4.x will pick arbitrary
|
||||
# SDK paths, ignoring xcode-select, if not given an explicit SDK.
|
||||
_qt_internal_get_apple_sdk_name(sdk_name)
|
||||
set(CMAKE_OSX_SYSROOT "${sdk_name}" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL iOS OR CMAKE_SYSTEM_NAME STREQUAL visionOS)
|
||||
|
|
|
@ -168,7 +168,7 @@ endif()")
|
|||
set(cmake_sysroot_name "$CACHE{CMAKE_OSX_SYSROOT}")
|
||||
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES _qt_osx_architectures_count)
|
||||
if(cmake_sysroot_name AND NOT _qt_osx_architectures_count GREATER 1 AND UIKIT)
|
||||
if(cmake_sysroot_name AND (MACOS OR (UIKIT AND NOT _qt_osx_architectures_count GREATER 1)))
|
||||
list(APPEND init_platform "
|
||||
if(NOT DEFINED CMAKE_OSX_SYSROOT)
|
||||
set(CMAKE_OSX_SYSROOT \"${cmake_sysroot_name}\" CACHE STRING \"\")
|
||||
|
|
Loading…
Reference in New Issue