I’ve long ached for a way to build Android applications solely in my own CMake-based projects. I simply despise Android Studio as I’m mostly interested in building C & C++ heavy applications with little to no need for Java. Something I’ve done for a long time is roll a custom target that would invoke the Android SDK tools to package an APK myself. However after recently learning a bit more about CPack I thought “Why can’t CPack create an APK?”
After rummaging through the CPack code I managed to add a custom APK generator that is very similar to the NuGet generator. You can find the code at my CMake fork on Github here: GitHub - Honeybunch/CMake: Mirror of CMake upstream repository
Most of the actual logic is housed in a CPackAPK.cmake script and cmCPackApkGenerator.cxx:
(I can’t link the full links due to being a new user )
You can also see how I’m using this in a personal project of mine here:
I’m making this topic for a few reasons:
#1 To gauge interest: Do people besides me actually want this?
#2 To gauge correctness of what I have so far: I’m new to hacking on CMake and I’d like some extra eyes on what I’ve done so far. I’ve read what docs and code I can find about what I’m trying to do but would love some feedback.
So, some questions I have:
Is this the sort of feature that Kitware would even accept? I have no idea if this is maybe some sort of ground that’s been covered before that I just can’t find the history on.
What kinds of horrible things have I done in my CPackAPK module? There are some obvious flaws that need correction (a more robust way of detecting the Android SDK) but I wonder what lurks beneath that someone as green as me would miss.
The CPackAPK module currently relies on the user having setup their install procedure to install files to a “normal-ish” android-style directory structure. How reasonable is this? I’ve found that the APK packaging tools are a bit picky about directories but I may just be using them wrong.
I see there are some tests for CPack but I haven’t made it there yet due to the above concerns. I assume that skipping tests would not be acceptable for submission?