cmake_minimum_required(VERSION 3.4.1)
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
set(OpenCV_DIR D:/android/OpenCV/OpenCV-3.2.0-android-sdk/sdk/native/jni)
find_package(OpenCV REQUIRED)
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
#include头文件目录
include_directories(../facefindlib/src/main/cpp/include
../facefindlib/src/main/cpp
)
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
find_package(OpenCV REQUIRED)
#source directory源文件目录
file(GLOB MTCNN_SRC src/main/cpp/*.h
src/main/cpp/*.cpp
)
set(MTCNN_COMPILE_CODE ${MTCNN_SRC})
#添加ncnn库
add_library(libncnn STATIC IMPORTED)
set_target_properties(libncnn
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libncnn.a)
#编译为动态库
add_library(mtcnn SHARED ${MTCNN_COMPILE_CODE})
#添加工程所依赖的库
find_library(log-lib log)
target_link_libraries(mtcnn
libncnn
jnigraphics
z
${log-lib}
${OpenCV_LIBS}
)