diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-10-05 14:49:39 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-10-06 06:31:18 +0200 |
commit | 1f52f45836351d4f79b954ffdb3bba018065eeaf (patch) | |
tree | 221cc0c04ac6a84743264572d6870b69d46bdc8b | |
parent | 260a6e86c2e7f52c9b9f0340249e88d7c56b6406 (diff) |
CMake: Implement missing Android-related configure options
Implement the last remaining Android-related configure options for the
CMake build.
Print warnings for options that have no equivalent in the CMake build.
Let -android-ndk automatically deduce the CMake toolchain file, and
error out if that fails with a hint how to fix the situation.
Task-number: QTBUG-85373
Change-Id: I8399e5334ae0f1f6634e381775a308d34f7c482b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 33 | ||||
-rw-r--r-- | cmake/configure-cmake-mapping.md | 12 |
2 files changed, 39 insertions, 6 deletions
diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index e28225f323..2189f1dbd5 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -565,6 +565,39 @@ endif() translate_string_input(platform QT_QMAKE_TARGET_MKSPEC) translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC) translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM) + +translate_path_input(android-sdk ANDROID_SDK_ROOT) +if(DEFINED INPUT_android-ndk) + drop_input(android-ndk) + set(toolchain_file "${INPUT_android-ndk}/build/cmake/android.toolchain.cmake") + if(EXISTS "${toolchain_file}") + message("Using CMake toolchain file: ${toolchain_file}") + else() + qtConfAddError("The toolchain file '${toolchain_file}' does not exist. " + "This file path was deduced from the -android-ndk option. Consider specifying " + "the correct toolchain file with -- -DCMAKE_TOOLCHAIN_FILE=<path>") + endif() + push("-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}") + unset(toolchain_file) +endif() +if(DEFINED INPUT_android-ndk-host) + drop_input(android-ndk-host) + qtConfAddWarning("The -android-ndk-host option is not supported with the CMake build. " + "Determining the right host platform is handled by the CMake toolchain file that is " + "located in your NDK.") +endif() +if(DEFINED INPUT_android-ndk-platform) + drop_input(android-ndk-platform) + string(REGEX REPLACE "^android-" "" INPUT_android-ndk-platform "${INPUT_android-ndk-platform}") + push("-DANDROID_NATIVE_API_LEVEL=${INPUT_android-ndk-platform}") +endif() +if(DEFINED INPUT_android-abis) + if(INPUT_android-abis MATCHES ",") + qtConfAddError("The -android-abis option cannot handle more than one ABI " + "when building with CMake.") + endif() + translate_string_input(android-abis ANDROID_ABI) +endif() translate_string_input(android-javac-source QT_ANDROID_JAVAC_SOURCE) translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET) diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index 95527273fd..6f7b7af71a 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -89,12 +89,12 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349. | -L <string> | -DQT_EXTRA_LIBDIRS=<string1>;<string2> | | | -F <string> | -DQT_EXTRA_FRAMEWORKPATHS=<string1>;<string2> | | | -sdk <sdk> | | | -| -android-sdk path | | | -| -android-ndk path | | | -| -android-ndk-platform | | | -| -android-ndk-host | | | -| -android-abis | | | -| -android-style-assets | | | +| -android-sdk <path> | -DANDROID_SDK_ROOT=<path> | | +| -android-ndk <path> | -DCMAKE_TOOLCHAIN_PATH=<toolchain file in NDK> | | +| -android-ndk-platform android-23 | -DCMAKE_ANDROID_NATIVE_API_LEVEL=23 | | +| -android-ndk-host | n/a | determined by toolchain file | +| -android-abis <abi_1>,...,<abi_n> | -DANDROID_ABI=<abi_1> | only one ABI can be specified | +| -android-style-assets | -DFEATURE_android_style_assets=ON | | | -android-javac-source | -DQT_ANDROID_JAVAC_SOURCE=7 | Set the javac build source version. | | -android-javac-target | -DQT_ANDROID_JAVAC_TARGET=7 | Set the javac build target version. | | -skip <repo> | -DBUILD_<repo>=OFF | | |