Building an(or multiple) android app(s) as part of an existing cmake project
MS_36 last edited by MS_36
I am currently trying to simplify the build of android apps using cmake and the changes made in Qt 5.14.
The project structure I am working with looks like this:
| CMake project libraries |- Library 1 |- Library 2 |- Library x
Before Qt 5.14 I had the following workflow to deploy my android apps:
1.) Build the CMake project (libraries) for android armv7
1.) Build the CMake project (libraries) for android arm64
2.) Opening the QtCreator projects(one per app) to build the app (once for armv7 and arm64 apks)
With Qt 5.14 I was hoping to simplify this to one single step:
| CMake project |- Library 1 |- Library 2 |- Library x |- App 1 |- App x
What I would like to have:
1.) Build the Cmake project -> It gets built for armv7 and arm64 and the aabs for the apps are generated
The CMake project existed before the android apps and from that perspective the apps are just another "executable" to me.
In fact I use the app built for Linux/Windows for debugging and developing so it really is just another executable to me that should be built with CMake.
I have the app projects in the one CMake project and building this for Linux/Windows works of course as expected.
I got as far as having the CMake project building all libraries correctly for armv7 and arm64.
FIND_PACKAGE( Qt5 )calls lead to CMake failing to generate because of the aab/apk target beeing defined multiple times.
This can be solved by playing around with
set( Projectname-MultiAbiBuild ON ), but it also limits the project to only having one app in it.
I never got it to build an aab or apk for me because the variables for that to work need to be set before the first
FIND_PACKAGE( Qt5 )call.
I may be wrong but to me it seems the new capabilities of Qt 5.14 expect me to have something like this:
| CMake project libraries |- Library 1 |- Library 2 |- Library x | CMake project App1 |- App1 | CMake project AppX |- AppX
1.) Build Cmake project libaries for armv7 and arm64(in one go)
2.) Build CMake project App1 aab for armv7 and arm64 (in one go)
3.) Build CMake project AppX aab for armv7 and arm64 (in one go)
If I assume correct there is no advantage for me in using CMake for the apps.
I guess I could get my one CMake project to build the apps using
ExternalProject_Add(<name> [<option>...])but I dont like that.
I would have to duplicate things again in the App CMake projects similar to what I have to do now in the QtCreator project.
Am I missing something obvious?
jheaff last edited by
I also have the same requirement of several Android applications within one CMake project. @MS_36 May I ask how you overcame this?