From 5b90b650a414c8088854e7ca84663aaa0f3528af Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 8 Oct 2020 19:32:16 +0200 Subject: CMake: Implement missing iOS-related configure options Detect an iOS build when either an -sdk option is passed or when -xplatform macx-ios-clang is passed as a target mkspec. Now that CMake 3.17 is released, change the default behavior of the iOS build to configure with simulator_and_device set to ON, like it is with qmake. Update the documentation regarding iOS configuration. Change-Id: I91aaf706610b8d3c69f1ad4ba9dadee2b1e5db97 Reviewed-by: Joerg Bornemann --- cmake/QtAutoDetect.cmake | 10 +++------- cmake/QtProcessConfigureArgs.cmake | 5 +++++ cmake/README.md | 6 +++--- cmake/configure-cmake-mapping.md | 7 +++++-- 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'cmake') diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index 5a575d2de3..cd5b3406cf 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -69,14 +69,10 @@ function(qt_auto_detect_ios) # If the variable is explicitly provided, assume simulator_and_device to be off. if(QT_UIKIT_SDK) set(simulator_and_device OFF) - elseif(QT_FORCE_SIMULATOR_AND_DEVICE) - # TODO: Once we get simulator_and_device support in upstream CMake, only then allow - # usage of simulator_and_device without forcing. - set(simulator_and_device ON) else() - # If QT_UIKIT_SDK is not provided, default to simulator. - set(simulator_and_device OFF) - set(QT_UIKIT_SDK "iphonesimulator" CACHE "STRING" "Chosen uikit SDK.") + # Default to simulator_and_device when an explicit sdk is not requested. + # Requires CMake 3.17.0+. + set(simulator_and_device ON) endif() message(STATUS "simulator_and_device set to: \"${simulator_and_device}\".") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 402ca52b24..455f98224d 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -601,6 +601,11 @@ endif() translate_string_input(android-javac-source QT_ANDROID_JAVAC_SOURCE) translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET) +translate_string_input(sdk QT_UIKIT_SDK) +if(DEFINED INPUT_sdk OR (DEFINED INPUT_xplatform AND INPUT_xplatform STREQUAL "macx-ios-clang")) + push("-DCMAKE_SYSTEM_NAME=iOS") +endif() + drop_input(make) drop_input(nomake) diff --git a/cmake/README.md b/cmake/README.md index e8bff0ab2b..504c7bedfc 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -178,11 +178,11 @@ In order to cross-compile Qt to iOS, you need a host macOS build. When running cmake in qtbase, pass ``-DCMAKE_SYSTEM_NAME=iOS -DQT_HOST_PATH=/path/to/your/host/build -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH`` -If you don't supply the configuration argument ``-DQT_UIKIT_SDK=...``, it will default to -``iphonesimulator``. To target another SDK / device type, use one of the following values: +If you don't supply the configuration argument ``-DQT_UIKIT_SDK=...``, CMake will build a +multi-arch simulator_and_device iOS build. +To target another SDK / device type, use one of the following values: * iphonesimulator: ``-DQT_UIKIT_SDK=iphonesimulator`` * iphoneos: ``-DQT_UIKIT_SDK=iphoneos`` - * simulator_and_device: ``-DQT_FORCE_SIMULATOR_AND_DEVICE=ON -DQT_UIKIT_SDK=`` Depending on what value you pass to ``-DQT_UIKIT_SDK=`` a list of target architectures is chosen by default: diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index 6f7b7af71a..487f9c7354 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -41,7 +41,8 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349. | -static | -DBUILD_SHARED_LIBS=OFF | | | -framework | -DFEATURE_framework=ON | | | -platform | -DQT_QMAKE_TARGET_MKSPEC= | | -| -xplatform | -DQT_QMAKE_TARGET_MKSPEC= | Only used for generating qmake-compatibility files. | +| -xplatform | -DQT_QMAKE_TARGET_MKSPEC= | Used for generating qmake-compatibility files. | +| | | If passed 'macx-ios-clang', will configure an iOS build. | | -device | equivalent to -xplatform devices/ | | | -device-option | -DQT_QMAKE_DEVICE_OPTIONS=key1=value1;key2=value2 | Only used for generation qmake-compatibility files. | | | | The device options are written into mkspecs/qdevice.pri. | @@ -88,7 +89,9 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349. | -I | -DQT_EXTRA_INCLUDEPATHS=; | | | -L | -DQT_EXTRA_LIBDIRS=; | | | -F | -DQT_EXTRA_FRAMEWORKPATHS=; | | -| -sdk | | | +| -sdk | -DQT_UIKIT_SDK= | Should be provided a value like 'iphoneos' or 'iphonesimulator' | +| | | If no value is provided, a simulator_and_device build is | +| | | assumed. | | -android-sdk | -DANDROID_SDK_ROOT= | | | -android-ndk | -DCMAKE_TOOLCHAIN_PATH= | | | -android-ndk-platform android-23 | -DCMAKE_ANDROID_NATIVE_API_LEVEL=23 | | -- cgit v1.2.3