I have CMake setup to build native shared libraries (*.so) that are
included in an APK built for Android. The "ant release" command is
invoked by a custom target I define in CMake, which handles building
the java pieces as well as packaging the final app into an APK file.

So the build pipeline when I invoke my custom target is:

Build Native Library (library target, output is *.so) -> Run Ant
Release (output is an APK)

This worked fine, until I needed to support multiple architectures on
the native side. So basically now I need to rebuild the C++ code 2
times: Once for ARM platform, another for x86 Android platform.

Once both native libraries are built (end up with two *.so files), I
need to copy both of those libraries into the android project
directory structure and run the custom target to do "ant release".
Since a single CMake binary directory is tied to 1 combination of
configuration/platform build for the C++ code, I can't make it build
twice through CMake itself.

Basically I've had to take away responsibility of the java build (via
the custom target) away from CMake and invoke it manually on the build
server. So our continuous build server does the following:

1. Generate CMake for ARM Android -> Build it -> Publish the *.so
2. Generate CMake for x86 Android -> Build it -> Publish the *.so
3. Gather previously published two *.so files, run "ant release" manually

The goal here is 1 APK that can be deployed to both platforms since it
has both shared libraries inside it. Android knows which shared
library to load when you launch the application based on whichever
platform you are on.

If I used the old method, I'd have 2 APK files (one for each platform)
which won't work for me.

Is there a way I can have CMake still responsible for running the
non-native tasks via custom commands and targets, while also building
two libraries? What would be the best setup for this?

Note that it is ideal to be able to replicate deployments locally, the
same way the build server would. So even if a single CMake binary
directory can't accomplish this somehow, I'd be OK with a superbuild
approach of some sort (superbuild would build the native parts 2
times, one for each platform, then do another CMake generate that just
runs custom targets and nothing else). Ideas are appreciated!
-- 

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://public.kitware.com/mailman/listinfo/cmake

Reply via email to