aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2018-04-06 14:17:12 +0200
committerAleix Pol <aleixpol@kde.org>2018-04-11 15:44:26 +0200
commit4baac2ecae1f23723d4fde4f346bdaa54112d9a2 (patch)
tree0bf747ce7d1a2371990687a52d306cfb0db587f7
parent731ba7036effcc430f98031e7f2a9826f6234cba (diff)
downloadextra-cmake-modules-4baac2ecae1f23723d4fde4f346bdaa54112d9a2.tar.gz
extra-cmake-modules-4baac2ecae1f23723d4fde4f346bdaa54112d9a2.tar.bz2
Android: Explicitly point at upstream documentation and deprecate duplicated concepts
Summary: Mark as deprecated the redundant variables and focus on the difference. Reviewers: #build_system, #frameworks, vkrause Reviewed By: vkrause Subscribers: vkrause Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D11984
-rw-r--r--toolchain/Android.cmake49
-rw-r--r--toolchain/deployment-file.json.in4
2 files changed, 28 insertions, 25 deletions
diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake
index 14d5b901..afe9b917 100644
--- 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 <http://doc.qt.io/qt-5/deployment-android.html>`_ 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
-# <http://developer.android.com/guide/topics/manifest/uses-sdk-element.html>`_
-# 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 @@ include(${CMAKE_ROOT}/Modules/Platform/Android-Initialize.cmake REQUIRED)
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 @@ if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME})
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
index 4eb579b5..f213f121 100644
--- 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@",