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>
This commit is contained in:
Joerg Bornemann 2020-10-05 14:49:39 +02:00
parent 260a6e86c2
commit 1f52f45836
2 changed files with 39 additions and 6 deletions

View File

@ -565,6 +565,39 @@ endif()
translate_string_input(platform QT_QMAKE_TARGET_MKSPEC) translate_string_input(platform QT_QMAKE_TARGET_MKSPEC)
translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC) translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC)
translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM) 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-source QT_ANDROID_JAVAC_SOURCE)
translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET) translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET)

View File

@ -89,12 +89,12 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349.
| -L <string> | -DQT_EXTRA_LIBDIRS=<string1>;<string2> | | | -L <string> | -DQT_EXTRA_LIBDIRS=<string1>;<string2> | |
| -F <string> | -DQT_EXTRA_FRAMEWORKPATHS=<string1>;<string2> | | | -F <string> | -DQT_EXTRA_FRAMEWORKPATHS=<string1>;<string2> | |
| -sdk <sdk> | | | | -sdk <sdk> | | |
| -android-sdk path | | | | -android-sdk <path> | -DANDROID_SDK_ROOT=<path> | |
| -android-ndk path | | | | -android-ndk <path> | -DCMAKE_TOOLCHAIN_PATH=<toolchain file in NDK> | |
| -android-ndk-platform | | | | -android-ndk-platform android-23 | -DCMAKE_ANDROID_NATIVE_API_LEVEL=23 | |
| -android-ndk-host | | | | -android-ndk-host | n/a | determined by toolchain file |
| -android-abis | | | | -android-abis <abi_1>,...,<abi_n> | -DANDROID_ABI=<abi_1> | only one ABI can be specified |
| -android-style-assets | | | | -android-style-assets | -DFEATURE_android_style_assets=ON | |
| -android-javac-source | -DQT_ANDROID_JAVAC_SOURCE=7 | Set the javac build source version. | | -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. | | -android-javac-target | -DQT_ANDROID_JAVAC_TARGET=7 | Set the javac build target version. |
| -skip <repo> | -DBUILD_<repo>=OFF | | | -skip <repo> | -DBUILD_<repo>=OFF | |