diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -9,9 +9,17 @@ # Furthermore, if desired, an APK can be directly generated by using the # `androiddeployqt `_ tool. # +# CMake upstream has Android support now. This module will still give us some +# useful features offering androiddeployqt integration and adequate executables +# format for our Android applications. +# +# Since we are using CMake Android support, any information from CMake documentation +# still applies: +# https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android +# # .. note:: # -# This module requires CMake 3.1. +# This module requires CMake 3.7. # # Since 1.7.0. # @@ -27,15 +35,13 @@ # can be done on the commandline or with environment variables; in either case # the variable names are: # -# ``ANDROID_NDK`` +# ``CMAKE_ANDROID_NDK`` # The NDK root path. # ``ANDROID_SDK_ROOT`` # The SDK root path. # # Additional options are specified as cache variables (eg: on the command line): # -# ``ANDROID_ARCHITECTURE`` -# The architecture to compile for. Default: ``arm``. # ``ANDROID_TOOLCHAIN`` # The toolchain to use. See the ``toolchains`` directory of the NDK. # Default: ``arm-linux-androideabi``. @@ -45,12 +51,6 @@ # ``ANDROID_ABI`` # The ABI to use. See the ``sources/cxx-stl/gnu-libstdc++/*/libs`` # directories in the NDK. Default: ``armeabi-v7a``. -# ``ANDROID_GCC_VERSION`` -# The GCC version to use. Default: ``4.9``. -# ``ANDROID_API_LEVEL`` -# The `API level -# `_ -# to require. Default: ``14``. # ``ANDROID_SDK_BUILD_TOOLS_REVISION`` # The build tools version to use. Default: ``21.1.1``. # @@ -135,22 +135,25 @@ cmake_minimum_required(VERSION "3.7") -#input -set(ANDROID_NDK "$ENV{ANDROID_NDK}" CACHE path "Android NDK path") +macro(set_deprecated_variable actual_variable deprecated_variable default_value) + set(${deprecated_variable} "${default_value}" CACHE STRING "Deprecated. Use ${actual_variable}") + if (NOT DEFINED ${${actual_variable}}) + set(${actual_variable} ${${deprecated_variable}}) + endif() +endmacro() + +set_deprecated_variable(CMAKE_ANDROID_NDK ANDROID_NDK "$ENV{ANDROID_NDK}") +set_deprecated_variable(CMAKE_ANDROID_ARCH ANDROID_ARCHITECTURE "arm") +set_deprecated_variable(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION ANDROID_GCC_VERSION "4.9") +set_deprecated_variable(CMAKE_ANDROID_ARCH_ABI ANDROID_ABI "armeabi-v7a") +set_deprecated_variable(CMAKE_ANDROID_API ANDROID_API_LEVEL "14") + set(ANDROID_SDK_ROOT "$ENV{ANDROID_SDK_ROOT}" CACHE path "Android SDK path") -set(ANDROID_ARCHITECTURE "arm" CACHE string "Used Architecture, related to the ABI and TOOLCHAIN") set(ANDROID_TOOLCHAIN "arm-linux-androideabi" CACHE string "Used SDK") set(ANDROID_COMPILER_PREFIX "arm-linux-androideabi" CACHE string "Prefix for gcc/g++/etc") -set(ANDROID_ABI "armeabi-v7a" CACHE string "Used ABI") -set(ANDROID_GCC_VERSION "4.9" CACHE string "Used GCC version" ) -set(ANDROID_API_LEVEL "14" CACHE string "Android API Level") set(ANDROID_SDK_BUILD_TOOLS_REVISION "21.1.1" CACHE string "Android API Level") - -set(CMAKE_ANDROID_NDK ${ANDROID_NDK}) -set(CMAKE_SYSTEM_VERSION ${ANDROID_API_LEVEL}) -set(CMAKE_ANDROID_ARCH ${ANDROID_ARCHITECTURE}) -set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ABI}) +set(CMAKE_SYSTEM_VERSION ${CMAKE_ANDROID_API}) set(CMAKE_SYSTEM_NAME Android) if (NOT CMAKE_ANDROID_STL_TYPE) set(CMAKE_ANDROID_STL_TYPE gnustl_shared) @@ -162,7 +165,7 @@ if (NOT DEFINED ECM_ADDITIONAL_FIND_ROOT_PATH) SET(ECM_ADDITIONAL_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH}) endif() -SET(CMAKE_FIND_ROOT_PATH ${ANDROID_NDK} ${ANDROID_NDK}/sysroot ${CMAKE_SYSROOT} ${ECM_ADDITIONAL_FIND_ROOT_PATH}) +SET(CMAKE_FIND_ROOT_PATH ${CMAKE_ANDROID_NDK} ${CMAKE_ANDROID_NDK}/sysroot ${CMAKE_SYSROOT} ${ECM_ADDITIONAL_FIND_ROOT_PATH}) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) @@ -192,7 +195,7 @@ find_package(Qt5Core REQUIRED) set(EXPORT_DIR "${CMAKE_BINARY_DIR}/${QTANDROID_EXPORTED_TARGET}_build_apk/") - set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/${ANDROID_ABI}/lib${QTANDROID_EXPORTED_TARGET}.so") + set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}/lib${QTANDROID_EXPORTED_TARGET}.so") set(QML_IMPORT_PATHS "") foreach(prefix ${ECM_ADDITIONAL_FIND_ROOT_PATH}) # qmlimportscanner chokes on symlinks, so we need to resolve those first diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -1,10 +1,10 @@ { "qt": "@_qt5Core_install_prefix@", "sdk": "@ANDROID_SDK_ROOT@", - "ndk": "@ANDROID_NDK@", + "ndk": "@CMAKE_ANDROID_NDK@", "toolchain-prefix": "@ANDROID_TOOLCHAIN@", "tool-prefix": "@ANDROID_COMPILER_PREFIX@", - "toolchain-version": "@ANDROID_GCC_VERSION@", + "toolchain-version": "@CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION@", "ndk-host": "@_LOWER_CMAKE_HOST_SYSTEM_NAME@-@CMAKE_HOST_SYSTEM_PROCESSOR@", "target-architecture": "@ANDROID_ABI@", "application-binary": "@EXECUTABLE_DESTINATION_PATH@",