This module requires CMake 3.7.
You will also need to provide the locations of the Android NDK and SDK. This can be done on the commandline or with environment variables; in either case the variable names are:
Additional options are specified as cache variables (eg: on the command line):
For integrating other libraries which are not part of the Android toolchain, like Qt5, and installed to a separate prefix on the host system, the install prefixes of those libraries would be passed as alternative roots as list via ECM_ADDITIONAL_FIND_ROOT_PATH. Since 5.30.0. For example, for integrating a Qt5 for Android with armv7 target present at /opt/android/Qt5/5.7/android_armv7 and some other libraries installed to the prefix /opt/android/foo, you would use:
cmake \ -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \ -DECM_ADDITIONAL_FIND_ROOT_PATH="/opt/android/Qt5/5.7/android_armv7;/opt/android/foo"
If your project uses find_package() to locate build tools on the host system, make sure to pass CMAKE_FIND_ROOT_PATH_BOTH or NO_CMAKE_FIND_ROOT_PATH as argument in the call. See the find_package() documentation for more details.
cmake \ -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \ -DQTANDROID_EXPORTED_TARGET=myapp \ -DANDROID_APK_DIR=myapp-apk make make create-apk-myapp
The APK would then be found in myapp_build_apk/bin in the build directory. The create-apk-myapp target will be able to take an ARGS parameter with further arguments for androiddeployqt. For example, one can use:
make create-apk-myapp ARGS="--install"
To install the apk to test. To generate a signed apk, one can do it with the following syntax:
make create-apk-myapp ARGS="--sign ~/my.keystore alias_name"
In case it’s needed for your application to set the APK directory from cmake scripting you can also set the directory as the ANDROID_APK_DIR property of the create-apk-myapp target. See Android documentation on how to create a keystore to use