[CMake] Android In-Depth CMake Questions

Gregory Peele ARA/CFD gpeele at ara.com
Fri Mar 16 13:12:13 EDT 2012


Hi all,

I'm experimenting with adding more in-depth support for Android to my CMake-based projects since I have a large body of CMake-built C++ code I want to use on Android (but not make Android-specific).  I used the Google Android toolchain file as a starting point for NDK support, and wrote a platform definition for Android so that the toolchain file only has to locate the right cross compiler. I also wrote functions to define Android APK targets using the Android SDK and Ant (for now) to compile the Java pieces and the final APK, where my functions deal with generating temporary Android projects for each APK target, generating an Android manifest from a template file based on CMake variables, and staging native CMake .so targets and non-system external libraries into the right spot to be put into the APK.   The APK install step also has an option to install to the Android emulator or attached devices using ADB.

First off, is there any general interest in this kind of work?  Would other people find this sort of thing useful in CMake itself?

Second, along the way I identified several challenges I wanted to ask for opinions on.

1.)  It's possible to build "fat" APKs with  multiple architectures for native libraries (Android supports ARMv5te, ARMv7-a, and x86).  CMake seemingly only has built-in support for fat binary compilation specific to the XCode generator for iOS.  How would one go about doing multi-arch compilation for native targets using the GNU or MinGW makefile generators?  Would this require changes to CMake itself or could it reasonably be scripted within the CMake language?  How does this interact with FIND_PACKAGE?

2.) ARM CPU targets have lots and lots of fun options that are not really Android specific (vanilla GCC/Linux ARM, Apple iOS builds, and presumably MSVC for Windows Mobile targets also have to deal with these).  Should there be a set of standard CMake options for ARM CPU targets to deal with things like which ISA to use, which FPU to use, whether to use ARM or Thumb instructions, etc.?  Similar idea would also be handy but less critical for x86 targets regarding target CPU capabilities like SSE3, etc.

3.) Android has (annoyingly convoluted) support for multiple C++ STL libraries with different capabilities and use cases which are NOT in the standard search directories (and are considered user libraries, not system libraries).  I more or less wrote a FindSTL script to deal with that, along with a FindCXX11 script to figure out how to set up a compiler to use native C++-11 constructs (or TR1 libraries or Boost as a fallback).   Is this a good way to deal with the problem?

Thanks for any advice or help you can offer.

Gregory Peele, Jr.
Senior Scientist
Applied Research Associates, Inc.
Central Florida Division

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120316/9648d683/attachment.htm>


More information about the CMake mailing list