1ECM-TOOLCHAINS(7)             Extra CMake Modules            ECM-TOOLCHAINS(7)
2
3
4

NAME

6       ecm-toolchains - ECM Toolchains Reference
7

INTRODUCTION

9       Extra  CMake Modules (ECM) provides some toolchain modules. Unlike nor‐
10       mal modules, these are not included directly in projects, but specified
11       with the CMAKE_TOOLCHAIN_FILE cache variable on the commandline.
12

ALL MODULES

14   AndroidToolchain
15       Enable easy compilation of cmake projects on Android.
16
17       By using this android toolchain, the projects will be set up to compile
18       the specified project targeting an Android platform, depending  on  its
19       input.   Furthermore,  if  desired, an APK can be directly generated by
20       using the androiddeployqt tool.
21
22       CMake upstream has Android support now. This module will still give  us
23       some  useful features offering androiddeployqt integration and adequate
24       executables format for our Android applications.
25
26       Since we are using CMake Android support, any  information  from  CMake
27       documentation                       still                      applies:
28       https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android
29
30       NOTE:
31          This module requires CMake 3.7.
32
33       Since 1.7.0.
34
35   Usage
36       To  use this file, you need to set the CMAKE_TOOLCHAIN_FILE to point to
37       Android.cmake on the command line:
38
39          cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake
40
41       You will also need to provide the locations of the Android NDK and SDK.
42       This  can  be done on the commandline or with environment variables; in
43       either case the variable names are:
44
45       CMAKE_ANDROID_NDK
46              The NDK root path.
47
48       ANDROID_SDK_ROOT
49              The SDK root path.
50
51       Additional options are specified as cache variables (eg: on the command
52       line):
53
54       ANDROID_ABI
55              The  ABI  to  use.  See the sources/cxx-stl/gnu-libstdc++/*/libs
56              directories in the NDK. Default: armeabi-v7a.
57
58       ANDROID_SDK_BUILD_TOOLS_REVISION
59              The build tools version to use. Default: 21.1.1.
60
61       ANDROID_EXTRA_LIBS
62              The “;”-separated list of full  paths  to  libs  to  include  in
63              resulting APK.
64
65       For  integrating  other  libraries  which  are  not part of the Android
66       toolchain, like Qt5, and installed to a separate  prefix  on  the  host
67       system,  the  install  prefixes  of  those libraries would be passed as
68       alternative roots  as  list  via  ECM_ADDITIONAL_FIND_ROOT_PATH.  Since
69       5.30.0.
70
71       For  example,  for  integrating  a  Qt5  for  Android with armv7 target
72       present at /opt/android/Qt5/5.7/android_armv7 and some other  libraries
73       installed to the prefix /opt/android/foo, you would use:
74
75          cmake \
76            -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \
77            -DECM_ADDITIONAL_FIND_ROOT_PATH="/opt/android/Qt5/5.7/android_armv7;/opt/android/foo"
78
79       If  your  project uses find_package() to locate build tools on the host
80       system,   make    sure    to    pass    CMAKE_FIND_ROOT_PATH_BOTH    or
81       NO_CMAKE_FIND_ROOT_PATH as argument in the call. See the find_package()
82       documentation for more details.
83
84   Deploying Qt Applications
85       After building the application, you will need to generate an  APK  that
86       can be deployed to an Android device. This module integrates androidde‐
87       ployqt support to help with this for Qt-based projects. To enable this,
88       set  the  QTANDROID_EXPORTED_TARGET variable to the targets you wish to
89       export as an APK (in a ;-separed list), as well as ANDROID_APK_DIR to a
90       directory  containing  some  basic information. This will create a cre‐
91       ate-apk-<target> target that will generate the APK file.  See the Qt on
92       Android deployment documentation for more information.
93
94       For example, you could do:
95
96          cmake \
97            -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \
98            -DQTANDROID_EXPORTED_TARGET=myapp \
99            -DANDROID_APK_DIR=myapp-apk
100          make
101          make create-apk-myapp
102
103       The  APK would then be found in myapp_build_apk/bin in the build direc‐
104       tory.
105
106       The create-apk-myapp target will be able to take an ARGS parameter with
107       further arguments for androiddeployqt. For example, one can use:
108
109          make create-apk-myapp ARGS="--install"
110
111       To  install  the  apk  to test. To generate a signed apk, one can do it
112       with the following syntax:
113
114          make create-apk-myapp ARGS="--sign ~/my.keystore alias_name"
115
116       In case it’s needed for your application to set the APK directory  from
117       cmake  scripting  you can also set the directory as the ANDROID_APK_DIR
118       property of the create-apk-myapp target.
119
120       See Android documentation on how to create a keystore to use
121

SEE ALSO

123       ecm(7)
124
126       KDE Developers
127
128
129
130
1315.64                             Nov 08, 2019                ECM-TOOLCHAINS(7)
Impressum