=====================================================================
程序A需要B库,B库需要C库
target_link_libraries(B C)
target_link_libraries(A B)
=====================================================================
生成对象库文件
add_library(hello SHARED hello.cpp) ==>libHello.so
add_library(hello STATIC hello.cpp) ==>libHello.a
=====================================================================
find_package命令
set(ncnn_DIR ${CMAKE_SOURCE_DIR}/${ANDROID_ABI}/lib/cmake/ncnn)
find_package(ncnn REQUIRED)
解析:
ncnn_DIR 目录下存放①ncnnConfig.cmake;②ncnn.cmake .
find_package命令执行后,
可以得到:
ncnn_INCLUDE_DIRS
ncnn_LIBS
之后就可使用
include_directories(${ncnn_INCLUDE_DIRS})
target_link_libraries(ncnnDemo ${ncnn_LIBS})
=====================================================================
add_subdirrctory命令
--jniDir
|--librtmp
|CMakeLists2.txt
|func.c
|CMakeLists1.txt
|native-lib.cpp
解析:
在CMakeLists1.txt当中 添加 add_subdirrctory(librtmp),
则CMakeLists1.txt会主动找到CMakeLists2.txt文件
=====================================================================
导入外部动态库
add_library(libopencv_java4 SHARED IMPORTED)
set_target_properties(libopencv_java4 PROPERTIES IMPORTED_LOCATION ${jnilibs}/${ANDROID_ABI}/libopencv_java4.so)
#解析:
#指定头文件的路径
include_directories(../cpp/opencv/include/)
#lib-native.so依赖libopencv_java4.so
target_link_libraries(lib-native libopencv_java4)
=====================================================================
导入外部静态库
=====================================================================
|