[FIXED] Android CMake: how to check if cppFlags and arguments are taken into account at compile time?

Issue

I have a Android/NDK/JNI/Java/C++ project.

I have a Gradle file that looks like this:

....
 cmake {
                cppFlags "-std=c++11 -fexceptions"
                arguments "-DANDROID_STL=c++_static"
            }
....

My question is: how to check that these flags and arguments are well taken into account when my Android project is compiled ?

Thanks

Solution

I have a big cmake file with parts like this:

            cmake {
                arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static"
                cFlags "-D__STDC_FORMAT_MACROS", "-fno-integrated-as", "-fvisibility=hidden"
                cppFlags "-fexceptions", "-frtti", "-fno-integrated-as", "-fvisibility=hidden"
            }

//...
        flavorDimensions "mode"

        productFlavors {
            normal {
                dimension "mode"
                externalNativeBuild {
                    cmake {
                        cFlags "-DNORMAL"
                        cppFlags "-DNORMAL"
                    }
                }
            }
            demo {
                dimension "mode"
                externalNativeBuild {
                    cmake {
                        cFlags "-DDEMO"
                        cppFlags "-DDEMO"
                    }
                }
            }
        }

and all options are taken into account. But you can check cmake cache files if you want. Build file is named build.ninja, and you can find it in your project variant folder inside .cxx folder.

In general, arguments are arguments that is passed to cmake, but cppFlags are flags that are passed to compiler.

Answered By – Afshin

Answer Checked By – Dawn Plyler (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published