Skip to content Skip to sidebar Skip to footer

Disabling A Cmake Target When Building Android App

I have an Android app that uses C++ native code which is built using CMake. In the project's CMakeLists a library is added using add_subdirectory(). This library has many targets,

Solution 1:

Google has thought of that: you can select which targets to build. The example below is a minimal version of the linked one; it only builds libexample-one:

android {
    defaultConfig {
        externalNativeBuild {
            cmake {
                // Note that  Gradle packages only shared libraries into your APK.
                targets "libexample-one"
            }
        }
    }
}

Alternatively you could hack the library's CMakeLists.txt to exclude the problematic targets from building automatically.

Post a Comment for "Disabling A Cmake Target When Building Android App"