.\" Man page generated from reStructuredText. . . .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 .. .TH "ECM-TOOLCHAINS" "7" "Nov 08, 2024" "6.8" "Extra CMake Modules" .SH NAME ecm-toolchains \- ECM Toolchains Reference .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 \X'tty: link https://doc.qt.io/qt-5/deployment-android.html'\fI\%androiddeployqt\fP\X'tty: link' 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: \X'tty: link https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android'\fI\%https://cmake.org/cmake/help/v3.7/manual/cmake\-toolchains.7.html#cross\-compiling\-for\-android\fP\X'tty: link' .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This module requires CMake 3.18. .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 .EX cmake \-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake .EE .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_COMPILE_API\fP The platform API level to compile against. May be different from the NDK target. Default: newest installed version (e.g. android\-30). .TP .B \fBANDROID_SDK_BUILD_TOOLS_REVISION\fP The build tools version to use. Default: newest installed version (e.g. \fB30.0.2\fP). .TP .B \fBANDROID_EXTRA_LIBS\fP The “;”\-separated list of full paths to libs to include in resulting APK (Qt 5 only). .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 present at \fB~/Qt/5.14.2/android/\fP and some other libraries installed to the prefix \fB/opt/android/foo\fP, you would use: .INDENT 0.0 .INDENT 3.5 .sp .EX cmake \e \-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \e \-DECM_ADDITIONAL_FIND_ROOT_PATH=\(dq~/Qt/5.14.2/android/;/opt/android/foo\(dq .EE .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 5 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 \X'tty: link https://doc.qt.io/qt-5/deployment-android.html'\fI\%Qt on Android deployment documentation\fP\X'tty: link' for more information. .sp For example, you could do: .INDENT 0.0 .INDENT 3.5 .sp .EX 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 .EE .UNINDENT .UNINDENT .sp You can specify the APK output directory by setting \fBANDROID_APK_OUTPUT_DIR\fP\&. Otherwise the APK can be found in \fBmyapp_build_apk/\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 .EX make create\-apk\-myapp ARGS=\(dq\-\-install\(dq .EE .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 .EX make create\-apk\-myapp ARGS=\(dq\-\-sign ~/my.keystore alias_name\(dq .EE .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 .SS Advanced Options .sp The following packaging options are mainly interesting for automation or integration with CI/CD pipelines: .INDENT 0.0 .TP .B \fBANDROID_APK_OUTPUT_DIR\fP Specifies a folder where the generated APK files should be placed. .TP .B \fBANDROID_FASTLANE_METADATA_OUTPUT_DIR\fP Specifies a folder where the generated metadata for the F\-Droid store should be placed. .TP .B \fBANDROIDDEPLOYQT_EXTRA_ARGS\fP Allows to pass additional arguments to \fIandroiddeployqt\fP\&. This is an alternative to the \fIARGS=\fP argument for \fImake\fP and unlike that works with all CMake generators. .UNINDENT .SH SEE ALSO .sp \fI\%ecm(7)\fP .SH COPYRIGHT KDE Developers .\" Generated by docutils manpage writer. .