diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2022-03-08 15:08:00 +0200 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2022-03-11 18:30:32 +0200 |
commit | db2f47337b3996ace994495d0de7d721f108e8f0 (patch) | |
tree | 26807d9082f426a9524d4032d1875b2615bd4f8b /cmake | |
parent | 888b75aa12e2cf35ee760bcf5cb1ed60fe0c0770 (diff) | |
download | qtbase-db2f47337b3996ace994495d0de7d721f108e8f0.tar.gz |
CMake:Android: Use ANDROID_PLATFORM instead of ANDROID_NATIVE_API_LEVEL
ANDROID_NATIVE_API_LEVEL is an alias for ANDROID_PLATFORM and the
Android's CMake docs [1] uses directly ANDROID_PLATFORM so let's use
that as well. Also, NDK r23b seems to have removed the part of code from
android.toolchain.cmake that handles ANDROID_NATIVE_API_LEVEL to set
the correct value to ANDROID_PLATFORM.
With this change, CMake will pass the value from the configure argument
-android-ndk-platform as -DANDROID_PLATFORM instead of
-DANDROID_NATIVE_API_LEVEL. Otherwise, if if -DANDROID_NATIVE_API_LEVEL
is passed directly to CMake, it should work as before.
[1] https://developer.android.com/ndk/guides/cmake#build-command
Pick-to: 6.3
Task-number: QTQAINFRA-4837
Change-Id: I5c21af53ac91e11a27c4b033313d22d1115c1abc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtAutoDetect.cmake | 6 | ||||
-rw-r--r-- | cmake/QtBaseConfigureTests.cmake | 2 | ||||
-rw-r--r-- | cmake/QtPriHelpers.cmake | 4 | ||||
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 3 | ||||
-rw-r--r-- | cmake/QtToolchainHelpers.cmake | 10 | ||||
-rw-r--r-- | cmake/README.md | 2 | ||||
-rw-r--r-- | cmake/configure-cmake-mapping.md | 2 |
7 files changed, 18 insertions, 11 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index 8450035084..14f220f69a 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -139,8 +139,10 @@ function(qt_auto_detect_android) if(android_detected) message(STATUS "Android build detected, checking configuration defaults...") - if(NOT DEFINED ANDROID_NATIVE_API_LEVEL) - message(STATUS "ANDROID_NATIVE_API_LEVEL was not specified, using API level 23 as default") + # ANDROID_NATIVE_API_LEVEL is an just an alias to ANDROID_PLATFORM, check for both + if(NOT DEFINED ANDROID_PLATFORM AND NOT DEFINED ANDROID_NATIVE_API_LEVEL) + message(STATUS "Neither ANDROID_PLATFORM nor ANDROID_NATIVE_API_LEVEL were specified, using API level 23 as default") + set(ANDROID_PLATFORM "android-23" CACHE STRING "") set(ANDROID_NATIVE_API_LEVEL 23 CACHE STRING "") endif() if(NOT DEFINED ANDROID_STL) diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake index 618554e16c..0bbcfb7ec7 100644 --- a/cmake/QtBaseConfigureTests.cmake +++ b/cmake/QtBaseConfigureTests.cmake @@ -254,6 +254,7 @@ function(qt_internal_print_cmake_android_info) message(STATUS "ANDROID_NDK: \"${ANDROID_NDK}\"") message(STATUS "ANDROID_ABI: \"${ANDROID_ABI}\"") message(STATUS "ANDROID_PLATFORM: \"${ANDROID_PLATFORM}\"") + message(STATUS "ANDROID_NATIVE_API_LEVEL: \"${ANDROID_NATIVE_API_LEVEL}\"") message(STATUS "ANDROID_STL: \"${ANDROID_STL}\"") message(STATUS "ANDROID_PIE: \"${ANDROID_PIE}\"") message(STATUS "ANDROID_CPP_FEATURES: \"${ANDROID_CPP_FEATURES}\"") @@ -261,7 +262,6 @@ function(qt_internal_print_cmake_android_info) message(STATUS "ANDROID_ARM_MODE: \"${ANDROID_ARM_MODE}\"") message(STATUS "ANDROID_ARM_NEON: \"${ANDROID_ARM_NEON}\"") message(STATUS "ANDROID_DISABLE_FORMAT_STRING_CHECKS: \"${ANDROID_DISABLE_FORMAT_STRING_CHECKS}\"") - message(STATUS "ANDROID_NATIVE_API_LEVEL: \"${ANDROID_NATIVE_API_LEVEL}\"") message(STATUS "ANDROID_LLVM_TRIPLE: \"${ANDROID_LLVM_TRIPLE}\"") endif() endfunction() diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake index 8f7e3e9b86..61080da7ef 100644 --- a/cmake/QtPriHelpers.cmake +++ b/cmake/QtPriHelpers.cmake @@ -792,7 +792,9 @@ function(qt_generate_global_device_pri_file) string(APPEND content "DEFAULT_ANDROID_NDK_ROOT = ${ANDROID_NDK}\n") set(android_platform "android-23") - if(ANDROID_NATIVE_API_LEVEL) + if(ANDROID_PLATFORM) + set(android_platform "${ANDROID_PLATFORM}") + elseif(ANDROID_NATIVE_API_LEVEL) set(android_platform "android-${ANDROID_NATIVE_API_LEVEL}") endif() string(APPEND content "DEFAULT_ANDROID_PLATFORM = ${android_platform}\n") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index c74fbbf733..09bc914f80 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -824,8 +824,7 @@ translate_path_input(android-sdk ANDROID_SDK_ROOT) translate_path_input(android-ndk ANDROID_NDK_ROOT) 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}") + push("-DANDROID_PLATFORM=${INPUT_android-ndk-platform}") endif() if(DEFINED INPUT_android-abis) if(INPUT_android-abis MATCHES ",") diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake index de8c1e8f52..f7ea59d1b5 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -184,13 +184,17 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file} list(APPEND init_platform "endif()") endif() elseif(ANDROID) - foreach(var ANDROID_NATIVE_API_LEVEL ANDROID_STL ANDROID_ABI - ANDROID_SDK_ROOT ANDROID_NDK_ROOT) + foreach(var ANDROID_PLATFORM ANDROID_NATIVE_API_LEVEL ANDROID_STL + ANDROID_ABI ANDROID_SDK_ROOT ANDROID_NDK_ROOT) list(APPEND init_additional_used_variables "list(APPEND __qt_toolchain_used_variables ${var})") endforeach() + + list(APPEND init_platform + "if(NOT DEFINED ANDROID_PLATFORM AND NOT DEFINED ANDROID_NATIVE_API_LEVEL)") list(APPEND init_platform - "set(ANDROID_NATIVE_API_LEVEL \"${ANDROID_NATIVE_API_LEVEL}\" CACHE STRING \"\")") + " set(ANDROID_PLATFORM \"${ANDROID_PLATFORM}\" CACHE STRING \"\")") + list(APPEND init_platform "endif()") list(APPEND init_platform "set(ANDROID_STL \"${ANDROID_STL}\" CACHE STRING \"\")") list(APPEND init_platform "set(ANDROID_ABI \"${ANDROID_ABI}\" CACHE STRING \"\")") list(APPEND init_platform "if (NOT DEFINED ANDROID_SDK_ROOT)") diff --git a/cmake/README.md b/cmake/README.md index 188c7caeea..7bb778a7ce 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -184,7 +184,7 @@ If you don't supply the configuration argument ``-DANDROID_ABI=...``, it will de * x86_64: ``-DANDROID_ABI=x86_64`` By default we set the android API level to 23. Should you need to change this supply the following -configuration argument to the above CMake call: ``-DANDROID_NATIVE_API_LEVEL=${API_LEVEL}`` +configuration argument to the above CMake call: ``-DANDROID_PLATFORM=android-${API_LEVEL}``. ### Cross compiling for iOS diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index 6874b909b3..b5935dec9b 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -92,7 +92,7 @@ The following table describes the mapping of configure options to CMake argument | | | assumed. | | -android-sdk <path> | -DANDROID_SDK_ROOT=<path> | | | -android-ndk <path> | -DCMAKE_TOOLCHAIN_FILE=<toolchain file in NDK> | | -| -android-ndk-platform android-23 | -DANDROID_NATIVE_API_LEVEL=23 | | +| -android-ndk-platform android-23 | -DANDROID_PLATFORM=android-23 | | | -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. | |