diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-03-22 15:35:14 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-04-03 17:17:11 +0200 |
commit | e23ea6a5d3bf09921bb98150a4f0f504e77ef4a3 (patch) | |
tree | 972bad260b595781c3bbcd7eaf79c3b0cfed020c /cmake/QtToolchainHelpers.cmake | |
parent | e3b36b65429f505522db2522798e72b334a11308 (diff) |
cmake: Propagate Qt's CMAKE_OSX_SYSROOT to user projects by SDK name
CMake will transform the CMAKE_OSX_SYSROOT into a path as part of
Darwin-initialize.cmake, as non-Xcode generators rely on it to
be a path when setting -isysroot.
When propagating the CMAKE_OSX_SYSROOT to consumers of Qt, we need
to propagate it by its original SDK name, so that CMake's Xcode
generator can write it by name into the SDKROOT Xcode setting by
name, and so that we don't lock the user into using the exact
same SDK path (and version) as we did when building Qt.
The QT_APPLE_SDK code path has been removed, as setting QT_APPLE_SDK
will always set the CMAKE_OSX_SYSROOT as well.
Change-Id: Ib1ef19b9dc375dddf76a2629ee790990c0722f75
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtToolchainHelpers.cmake')
-rw-r--r-- | cmake/QtToolchainHelpers.cmake | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake index e5409b9ffd..26b44bb10c 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -144,26 +144,26 @@ endif()") unset(init_additional_used_variables) if(APPLE) - # For an iOS simulator_and_device build, we should not explicitly set the sysroot, but let - # CMake do it's universal build magic to use one sysroot / sdk per-arch. - # For a single arch / sysroot iOS build, try to use the initially configured sysroot - # path if it exists, otherwise just set the name of the sdk to be used. - # The latter "name" part is important for user projects so that running 'xcodebuild' from - # the command line chooses the correct sdk. + # For an iOS simulator_and_device build, we should not explicitly set the sysroot, + # but let CMake do it's universal build magic to use one sysroot / sdk per-arch. + # For a single arch / sysroot build, try to use the initially configured sysroot + # by name. + # # Also allow to opt out just in case. # # TODO: Figure out if the same should apply to universal macOS builds. + # We want to preserve the sysroot as an SDK name, instead of the path + # that CMake transforms it into in Darwin-initialize.cmake, so we pick + # it out from the cache, where it hasn't been touched by CMake. + set(cmake_sysroot_name "$CACHE{CMAKE_OSX_SYSROOT}") + list(LENGTH CMAKE_OSX_ARCHITECTURES _qt_osx_architectures_count) - if(CMAKE_OSX_SYSROOT AND NOT _qt_osx_architectures_count GREATER 1 AND UIKIT) + if(cmake_sysroot_name AND NOT _qt_osx_architectures_count GREATER 1 AND UIKIT) list(APPEND init_platform " - 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_apple_sdk}\" CACHE PATH \"\") - endif()") +if(NOT DEFINED CMAKE_OSX_SYSROOT) + set(CMAKE_OSX_SYSROOT \"${cmake_sysroot_name}\" CACHE STRING \"\") +endif()") endif() if(CMAKE_OSX_DEPLOYMENT_TARGET) |