Issue
There are several native libs in this Android app. One of them ("vulkan_info") will only build with the argument "-DANDROID_PLATFORM=android-24." However, the other libs need to support minSdkVersion 16.
Using the build.gradle section posted below, the arguments "-DANDROID_ARM_NEON=TRUE" "-DANDROID_PLATFORM=android-24" apply to all of the targets. Everything works fine on SDK 24+ but not on earlier versions of Android. I would like the "mali_info" and "adreno_info" libraries to work on earlier Android versions.
How do I specify the cmake arguments so they only apply to "vulkan_info" and not to the other targets? Or alternatively, how could I specify different arguments for each target? Maybe I could do this in CMakeLists.txt? I'm using Android Studio
build.gradle
externalNativeBuild {
cmake {
targets 'mali_info' //I don't want the arguments to apply to this
targets 'adreno_info' //or this
targets 'vulkan_info' //the arguments below need to apply to this
arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_PLATFORM=android-24"
}
}
CmakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
add_library(
adreno_info
SHARED
src/main/cpp/adreno_info.cpp
)
target_link_libraries(
adreno_info
log
)
add_library(
mali_info
SHARED
src/main/cpp/mali_info.cpp
)
target_link_libraries(
mali_info
log
)
add_library(
vulkan_info
SHARED
src/main/cpp/vulkan_info.cpp
)
target_link_libraries(
vulkan_info
vulkan
log
)
Solution
There is no way to do that in the scope of one gradle project. You have two options:
- Split the gradle project into multiple
- Compile shared libraries outside gradle and add them via
android.sourceSets.main.jniLibs.srcDirs
Answered By - George Shakula Answer Checked By - Willingham (WPSolving Volunteer)