I have a cross-platform library with a layout based on a cmake script. Since cmake support for Android is now available ( https://developer.android.com/studio/projects/add-native-code.html ), I plan to move the ndk-build make files to the trash.
I tested find_package(ZLIB REQUIRED)
and it works well because the zlib headers and the library itself are available for all ABIs in the sysroot NDK. Thus, I can add any custom argument to cmake cmdline for each flavor or build type:
buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' externalNativeBuild { cmake { arguments "-DMYLIB_ENABLE_PROGUARD=ON" } } } debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' externalNativeBuild { cmake { arguments "-DMYLIB_ENABLE_PROGUARD=OFF" } } } }
My problem is the ability to set CMAKE_PREFIX_PATH
for each ABI to search for external static / shared libraries through FindPackage.
As a rule, I can use find_library
and include_directories
in combination with ${ANDROID_ABI}
in the cmake script itself, but I already have a working script with support for several platforms, I do not want to add dirty code, because there is a clean path (find_package + CMAKE_PREFIX_PATH) .
Thank you all for your time!
source share