Turn on compiler optimization for Android Studio debug build via Cmake

Viewed 2033

I am using Android Studio 3.0 for my NDK based app. For the C++ code, I use CMake as the external builder.

This works well, I can create debug and release binaries.

However, I would like to turn on compiler optimizations (say -O3) for a part of the C++ code (the physics engine), not just for the release build, but also for the debug build.

So create the bulk of the debug build as is, without optimizing, yet, I want one of the static library targets to be built with the compiler optimization enabled.

How can I go about this?

I have a CMakeLists for a static library target that gets included using add_subdirectory() directive in the top level CMakeLists file.

Note that I point to the top level CMakeLists in my app's build.gradle file like this:

externalNativeBuild {
    cmake {
        path '../../Android/jni/CMakeLists.txt'
    }
}
1 Answers
Related