[CMake] CMake for Android projects

Eric Wing ewmailing at gmail.com
Tue May 6 19:59:17 EDT 2014


So I have 4 examples I actually tried to document.
These all use my fork/derivative of the Android-CMake toolchain, which
I believe comes from OpenCV. (It had grown stale with later NDKs and I
hit problems). All of these rely heavily on the external NDK module
system (NDK_MODULE_PATH).

The first and easiest (most self contained) is:
https://bitbucket.org/ewing/hello-android-almixer
This one invokes ant via shell scripts outside CMake.

I then recently got SDL building with CMake using the same techniques.
https://bitbucket.org/ewing/sdl_android_cleanup
This one doesn't invoke ant because it builds only a library. There
was actually an intermediate project I helped build after ALmixer that
this also drew from, JavaScriptCore, and I documented my procedure
here:
https://github.com/appcelerator/hyperloop/wiki/Building-JavaScriptCore-for-Android


Once you have SDL built, and you set your NDK_MODULE_PATH directly, I
have an Ant example and Gradle example. The ant one is just like
Hello-Android-ALmixer.
https://bitbucket.org/ewing/helloandroidsdl-ant
https://bitbucket.org/ewing/helloandroidsdl-gradle

The Gradle one is a lot of hacks. Google is ditching Ant/Eclipse for
Gradle/IntelliJ, but their NDK support is even worse in the latter
right now.

Again, once you leave the NDK, all these things live outside CMake. I
think it would be interesting to make CMake handle all of this, but I
can't visualize it yet. But I hope others might be able to build on my
work, like how I've built on Android-CMake.

An aside, I noticed Gradle is painfully slow. Depending on how one
does CMake integration, I'm not sure I want it. Just to invoke it and
for it to figure out no real work needs to be done is measured in
seconds for me.


Thanks,
Eric



On 5/6/14, J Decker <d3ck0r at gmail.com> wrote:
> This is a page on building to android; mostly it's about my library, but
> names can be replaced where required
> https://code.google.com/p/c-system-abstraction-component-gui/wiki/BuildingForAndroid
>
> I went wit the separate cmake projects because I end up with multiple
> android projects from the same libraries; but really it could be appended
> all-together
>
>
> On Tue, May 6, 2014 at 2:32 PM, Robert Dailey
> <rcdailey.lists at gmail.com>wrote:
>
>> Well to be clear, the NDK libraries are compiled in eclipse after I
>> generate eclipse makefiles in CMake. Ideally, I want the CMake script
>> to also configure "ant" execution so that it builds java and links in
>> the NDK libraries. You say "just use the libraries", but I'm not sure
>> what this looks like as far as CMake script is concerned.
>>
>> Also I think we're using the android glue stuff in our existing
>> project, but I'm not really sure what android glue is or if it is
>> relevant to the CMake setup.
>>
>> On Tue, May 6, 2014 at 2:45 PM, J Decker <d3ck0r at gmail.com> wrote:
>> > If you've built the sources into libs, you can just use the lib; my
>> sources
>> > are much too complex of a tree for ndk to support to build as sources..
>> >
>> > The java sources are compiled at the 'ant <debug/release' step... there
>> is a
>> > step before that I do that is 'android.bat update project --target
>> > "android-14" --path' which makes a few other files from the build.xml.
>> >
>> >
>> > On Tue, May 6, 2014 at 8:42 AM, Robert Dailey
>> > <rcdailey.lists at gmail.com>
>> > wrote:
>> >>
>> >> There is also the question of how to handle the NDK sources and
>> >> integrate them into the eclipse workspace. For example, I believe NDK
>> >> sources must be under the 'jni' directory, but they won't be
>> >> structured that way in the source tree. So I'm not sure if the jni
>> >> directory is required. I realize there's some reference material out
>> >> there but I'm not sure what to pay attention to. Would be nice to get
>> >> some overview steps that I can read along with the reference material
>> >> so I know the order in which to look at things, essentially.
>> >>
>> >> On Tue, May 6, 2014 at 10:32 AM, Bill Hoffman
>> >> <bill.hoffman at kitware.com
>> >
>> >> wrote:
>> >> > You can look at what we did for VES:
>> >> > http://www.kitware.com/blog/home/post/642
>> >> >
>> >> >
>> >> > -Bill
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> >
>> >> > Powered by www.kitware.com
>> >> >
>> >> > Please keep messages on-topic and check the CMake FAQ at:
>> >> > http://www.cmake.org/Wiki/CMake_FAQ
>> >> >
>> >> > Kitware offers various services to support the CMake community. For
>> more
>> >> > information on each offering, please visit:
>> >> >
>> >> > CMake Support: http://cmake.org/cmake/help/support.html
>> >> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> >> > CMake Training Courses: http://cmake.org/cmake/help/training.html
>> >> >
>> >> > Visit other Kitware open-source projects at
>> >> > http://www.kitware.com/opensource/opensource.html
>> >> >
>> >> > Follow this link to subscribe/unsubscribe:
>> >> > http://www.cmake.org/mailman/listinfo/cmake
>> >> --
>> >>
>> >> Powered by www.kitware.com
>> >>
>> >> Please keep messages on-topic and check the CMake FAQ at:
>> >> http://www.cmake.org/Wiki/CMake_FAQ
>> >>
>> >> Kitware offers various services to support the CMake community. For
>> >> more
>> >> information on each offering, please visit:
>> >>
>> >> CMake Support: http://cmake.org/cmake/help/support.html
>> >> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> >> CMake Training Courses: http://cmake.org/cmake/help/training.html
>> >>
>> >> Visit other Kitware open-source projects at
>> >> http://www.kitware.com/opensource/opensource.html
>> >>
>> >> Follow this link to subscribe/unsubscribe:
>> >> http://www.cmake.org/mailman/listinfo/cmake
>> >
>> >
>>
>


-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


More information about the CMake mailing list