From 1f52f45836351d4f79b954ffdb3bba018065eeaf Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 5 Oct 2020 14:49:39 +0200 Subject: [PATCH] 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 --- cmake/QtProcessConfigureArgs.cmake | 33 ++++++++++++++++++++++++++++++ cmake/configure-cmake-mapping.md | 12 +++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index e28225f323b..2189f1dbd5b 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=") + 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 95527273fdc..6f7b7af71a2 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 | -DQT_EXTRA_LIBDIRS=; | | | -F | -DQT_EXTRA_FRAMEWORKPATHS=; | | | -sdk | | | -| -android-sdk path | | | -| -android-ndk path | | | -| -android-ndk-platform | | | -| -android-ndk-host | | | -| -android-abis | | | -| -android-style-assets | | | +| -android-sdk | -DANDROID_SDK_ROOT= | | +| -android-ndk | -DCMAKE_TOOLCHAIN_PATH= | | +| -android-ndk-platform android-23 | -DCMAKE_ANDROID_NATIVE_API_LEVEL=23 | | +| -android-ndk-host | n/a | determined by toolchain file | +| -android-abis ,..., | -DANDROID_ABI= | 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 | -DBUILD_=OFF | |