cmake调用第三方库

1
2
3
4
5
6
7
8
9
10
11
set(LIBSOCK_DIR /Users/hwp/work/eton_prj/smart_house_prj/source_demo/AndroidJni/app/libs/)
add_library(
test-lib
SHARED
IMPORTED
)
set_target_properties(
test-lib
PROPERTIES IMPORTED_LOCATION
${LIBSOCK_DIR}/${ANDROID_ABI}/libtest-lib.so
)
1
2
3
4
5
6
target_link_libraries( # Specifies the target library.
native-lib
test-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )

Build.gradle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
externalNativeBuild {
cmake {
cppFlags "-DDebug"
}
}
ndk{
abiFilters "armeabi-v7a"
}

sourceSets {
main {
jniLibs.srcDirs = ['/Users/hwp/work/eton_prj/smart_house_prj/source_demo/AndroidJni/app/libs']
}
}