[cmake-developers] [Generator] Android.mk

Vince Harron vharron at google.com
Thu Jan 9 01:45:01 EST 2014


> Can you explain more why this generator is needed?

There are a handful of different reasons.

It's true that generic makefiles can be made used to generate binaries for
pretty much any platform.  That said, cmake still has non-make generators
like Xcode and Visual Studio.  I consider this another example of that.

If your cmake-based project needs to interoperate with other projects that
use Visual Studio projects, it is most convenient to generate Visual Studio
project files from cmake

Similarly, if your cmake-based project needs to interoperate with other
projects that use Android.mk files, it is most convenient to generate
Android.mk files from cmake.

Android.mk files allow you to target multiple processor
architectures/variants in one make invocation without any reconfiguring or
multiple build folders.  All of those binaries are embedded into one "fat"
apk file that will run on any supported Android device.  This is important
to the processor independence goals of the Android project.  It also lets
you switch between different clang/gcc compilers trivially, which helps
significantly when testing code across multiple compilers.

This method of building modules is also used in building Android itself.
 Instead of a collection of recursive makefiles, all modules are built in a
single make invocation, which is faster.

Read "Recursive Make Considered Harmful" if you're interested in learning
more.
http://aegis.sourceforge.net/auug97.pdf

> Modules/Platform/Android.cmake

I've just started playing with it like this as my Android.cmake

include(Platform/Linux)

But it's critical to have Android as a separate CMAKE_SYSTEM_NAME because
there are many differences that you might want to switch on.

> Why does that link also say that Android.mk files are only for creating
shared and static libraries? Am I missing something here?

All Android applications start life as Java processes.  A java process can
load a native shared library and invoke code within it.  To emit a C/C++
executable on Android is the same as to emit a shared library, but linked
to something called the native_app_glue module.


Date: Tue, 07 Jan 2014 17:12:29 +0100
> From: Stephen Kelly <steveire at gmail.com>
> Subject: Re: [cmake-developers] [Generator] Android.mk
> To: cmake-developers at cmake.org
> Message-ID: <lah910$8q8$1 at ger.gmane.org>
> Content-Type: text/plain; charset="ISO-8859-1"
>
> Vince Harron wrote:
>
> > Hi all,
> >
> > Thomas Richard asked this question a while back.
> >
> >
> http://public.kitware.com/pipermail/cmake-developers/2013-March/006825.html
> >
> > I would also like to see support for generating Android.mk files from
> > CMake.
>
> Hi,
>
> Thanks for offering this. I'm no Android expert, but I've built
> applications
> and libraries for android with normal makefiles, as have others. Can you
> explain more why this generator is needed?
>
> This is a bit orthogonal but it seems to me that it would be worthwhile to
> create an Modules/Platform/Android.cmake file to make it easier to target
> Android with existing generators. Is there some way that that is too
> limited?>
>
> [aside: I see on http://www.kandroid.org/ndk/docs/ANDROID-MK.html that
> there
> is a LOCAL_CPP_FEATURES API. That's good independent validation of my
> design
> for cmake compiler features
>
> http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/6726/focus=7746
> ]
>
> Why does that link also say that Android.mk files are only for creating
> shared and static libraries? Am I missing something here?
>
> Thanks,
>
> Steve.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140108/eb2c1baf/attachment.html>


More information about the cmake-developers mailing list