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 - "set(ANDROID_NATIVE_API_LEVEL \"${ANDROID_NATIVE_API_LEVEL}\" CACHE STRING \"\")") + "if(NOT DEFINED ANDROID_PLATFORM AND NOT DEFINED ANDROID_NATIVE_API_LEVEL)") + list(APPEND init_platform + " 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 | -DANDROID_SDK_ROOT= | | | -android-ndk | -DCMAKE_TOOLCHAIN_FILE= | | -| -android-ndk-platform android-23 | -DANDROID_NATIVE_API_LEVEL=23 | | +| -android-ndk-platform android-23 | -DANDROID_PLATFORM=android-23 | | | -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. |