diff options
Diffstat (limited to 'cmake/QtToolchainHelpers.cmake')
-rw-r--r-- | cmake/QtToolchainHelpers.cmake | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake index 00ee5d8b33..5ab1236b8f 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -104,13 +104,26 @@ function(qt_internal_create_toolchain_file) unset(init_additional_used_variables) if(APPLE) - # For simulator_and_device build, we should not explicitly set the sysroot. + + # 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. + # Also allow to opt out just in case. + # + # TODO: Figure out if the same should apply to universal macOS builds. + 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_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 \"\") endif()") endif() @@ -151,14 +164,22 @@ function(qt_internal_create_toolchain_file) # This is line with default CMake behavior for user projects. # # For iOS, we provide a bit more convenience. - # When the user project is built using the Xcode generator, don't specify a default + # When the user project is built using the Xcode generator, we only specify the architecture + # if this is a single architecture Qt for iOS build. If we wouldn't, invoking just + # xcodebuild from the command line would try to build with the wrong architecture. Also + # provide an opt-out option just in case. + # + # For a multi-architecture build (so simulator_and_device) we don't set an explicit # architecture and let Xcode and the developer handle it. + # # When using the Ninja generator, specify the first architecture from QT_OSX_ARCHITECTURES # (even with a simulator_and_device Qt build). This ensures that the default configuration # at least tries to build something. if(UIKIT) 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)") + 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))") list(APPEND init_platform " set(CMAKE_OSX_ARCHITECTURES \"${osx_first_arch}\" CACHE STRING \"\")") list(APPEND init_platform "endif()") |