Running CMake from command line within an Android NDK project

 

Questions


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?

 

 

————————————————-

Answer

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 
    -DANDROID_ABI=whatever $YOUR_SOURCE_DIR

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

android,android-ndk,cmake

Facebook Comments

Post a comment