Running CMake from command line within an Android NDK project



How might one run an NDK Cmake build independently from the rest of an Android project, ideally from the command line, external to Android Studio?

The equivalent of running ndk-build from the jni directory for slightly older Android NDK projects.

I need to investigate exactly what the calls to the compiler look like, and I can’t seem to get this information when building the whole project from within Android Studio

My first attempt was just to run cmake from the project/app directory containing CMakeLists.txt, but this informs me that cmake is not installed – so how is Android Studio managing to build it then?





If your goal is to just run from the command line (as opposed to trying to do exactly what gradle is doing), just use cmake the way you normally would:

$ cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake 

Alternatively, you can just run ./gradlew from the command line.


Facebook Comments

Post a comment