I am trying to use an existing native library as part of an android project. I followed instructions about adding C and C++ Code to a project for android studio. I got to the point where I have a functioning CMakeLists.txt file (tested independently) and I've instructed gradle to use it to compile the native code.
The library I'm using uses make so I use ExternalProject_Add to instruct cmake how to compile it. Here is the relevant code:
ExternalProject_Add(foo
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libfoo
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../libfoo/configure
--host=arm-linux-androideabi
BUILD_COMMAND ${MAKE}
INSTALL_COMMAND true)
This is the relevant part of the build.gradle for the module:
externalNativeBuild {
cmake {
path '../cpp/CMakeLists.txt'
}
}
When I run ./gradlew assembleDebug
, the external project is not compiled. After adding an executable (named bar
) that depends on foo
in cmake, the configure step runs but the build step doesn't. I modified the code of the library so that compilation would fail, but gradle returns success anyway).
Here are the last lines of the output of ./gradlew assembleDebug
after these changes.
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
[6/10] Performing build step for 'foo'
[7/10] Performing install step for 'foo'
[8/10] Completed 'foo'
[9/10] Building C object CMakeFiles/bar.dir/bar.c.o
[10/10] Linking C executable bar
BUILD SUCCESSFUL in 18s
Any ideas what is happening? What am I doing wrong?
I'm using gradle 4.1 and cmake 3.6.