.\" Man page generated from reStructuredText. . .TH "ECM-TOOLCHAINS" "7" "Jan 17, 2019" "5.54" "Extra CMake Modules" .SH NAME ecm-toolchains \- ECM Toolchains Reference . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH INTRODUCTION .sp Extra CMake Modules (ECM) provides some toolchain modules. Unlike normal modules, these are not included directly in projects, but specified with the \fBCMAKE_TOOLCHAIN_FILE\fP cache variable on the commandline. .SH ALL MODULES .SS AndroidToolchain .sp Enable easy compilation of cmake projects on Android. .sp By using this android toolchain, the projects will be set up to compile the specified project targeting an Android platform, depending on its input. Furthermore, if desired, an APK can be directly generated by using the \fI\%androiddeployqt\fP tool. .sp 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. .sp Since we are using CMake Android support, any information from CMake documentation still applies: \fI\%https://cmake.org/cmake/help/v3.7/manual/cmake\-toolchains.7.html#cross\-compiling\-for\-android\fP .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This module requires CMake 3.7. .UNINDENT .UNINDENT .sp Since 1.7.0. .SS Usage .sp To use this file, you need to set the \fBCMAKE_TOOLCHAIN_FILE\fP to point to \fBAndroid.cmake\fP on the command line: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake \-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake .ft P .fi .UNINDENT .UNINDENT .sp 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: .INDENT 0.0 .TP .B \fBCMAKE_ANDROID_NDK\fP The NDK root path. .TP .B \fBANDROID_SDK_ROOT\fP The SDK root path. .UNINDENT .sp Additional options are specified as cache variables (eg: on the command line): .INDENT 0.0 .TP .B \fBANDROID_ABI\fP The ABI to use. See the \fBsources/cxx\-stl/gnu\-libstdc++/*/libs\fP directories in the NDK. Default: \fBarmeabi\-v7a\fP\&. .TP .B \fBANDROID_SDK_BUILD_TOOLS_REVISION\fP The build tools version to use. Default: \fB21.1.1\fP\&. .TP .B \fBANDROID_EXTRA_LIBS\fP The “;”\-separated list of full paths to libs to include in resulting APK. .UNINDENT .sp 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 \fBECM_ADDITIONAL_FIND_ROOT_PATH\fP\&. Since 5.30.0. .sp For example, for integrating a Qt5 for Android with armv7 target present at \fB/opt/android/Qt5/5.7/android_armv7\fP and some other libraries installed to the prefix \fB/opt/android/foo\fP, you would use: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake \e \-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \e \-DECM_ADDITIONAL_FIND_ROOT_PATH="/opt/android/Qt5/5.7/android_armv7;/opt/android/foo" .ft P .fi .UNINDENT .UNINDENT .sp If your project uses \fBfind_package()\fP to locate build tools on the host system, make sure to pass \fBCMAKE_FIND_ROOT_PATH_BOTH\fP or \fBNO_CMAKE_FIND_ROOT_PATH\fP as argument in the call. See the \fBfind_package()\fP documentation for more details. .SS Deploying Qt Applications .sp After building the application, you will need to generate an APK that can be deployed to an Android device. This module integrates androiddeployqt support to help with this for Qt\-based projects. To enable this, set the \fBQTANDROID_EXPORTED_TARGET\fP variable to the targets you wish to export as an APK (in a ;\-separed list), as well as \fBANDROID_APK_DIR\fP to a directory containing some basic information. This will create a \fBcreate\-apk\-\fP target that will generate the APK file. See the \fI\%Qt on Android deployment documentation\fP for more information. .sp For example, you could do: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake \e \-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \e \-DQTANDROID_EXPORTED_TARGET=myapp \e \-DANDROID_APK_DIR=myapp\-apk make make create\-apk\-myapp .ft P .fi .UNINDENT .UNINDENT .sp The APK would then be found in \fBmyapp_build_apk/bin\fP in the build directory. .sp The create\-apk\-myapp target will be able to take an ARGS parameter with further arguments for androiddeployqt. For example, one can use: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make create\-apk\-myapp ARGS="\-\-install" .ft P .fi .UNINDENT .UNINDENT .sp To install the apk to test. To generate a signed apk, one can do it with the following syntax: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make create\-apk\-myapp ARGS="\-\-sign ~/my.keystore alias_name" .ft P .fi .UNINDENT .UNINDENT .sp 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. .sp See Android documentation on how to create a keystore to use .SH SEE ALSO .sp \fBecm(7)\fP .SH COPYRIGHT KDE Developers .\" Generated by docutils manpage writer. .