andreas-hofmann
andreas-hofmann

Reputation: 2518

Include CMake project in AOSP build

I have a android-ndk based app, which is built with cmake, and I want to integrate that project into an AOSP-build and have it included in the resulting android image. However there seems to be no possibility to directly start a cmake build in the AOSP build system.

For example in the android-7.1.1._r35 source tree, the zlib-external has a CMakeLists.txt, but additionally an Android.mk file, which seems to actually be used for compilation with AOSP instead of cmake. The build instructions are duplicated in both files:

external/zlib/src/CMakeLists.txt
external/zlib/Android.mk

Since the project has quite a lot of source files (~1500 cpps), I'm trying to avoid the tedious task of converting and maintaining an extra build system.

Is it possible to invoke a cmake build from the Android.mk based build system or do I have to write an Android.mk file to build my app? If cmake can be called, how do I do it?

Upvotes: 5

Views: 2510

Answers (3)

tigerZ
tigerZ

Reputation: 179

  1. Add a shell script to run cmake and make command
  2. invoke the shell script in Android.mk file, like:
    SHELL_RESULT := $(shell ($(LOCAL_PATH)/run_cmake.sh))
    

Upvotes: 0

andreas-hofmann
andreas-hofmann

Reputation: 2518

For the record, in case someone stumbles upon this in the future: There seems to be a solution, though it's hacky - see Build gradle system app as part of AOSP build for reference. This solution seems to work, but the gradle/cmake build is started directly when the makefiles are parsed.

Upvotes: 1

Dan Albert
Dan Albert

Reputation: 10509

It is not possible to build cmake projects in the AOSP build system.

Upvotes: 0

Related Questions