qq_42837003
薛定呃的猫
2021-01-24 18:50

请帮我看看为什么as中这样书写cmakelist.txt无法调用opencv中头文件?

  • android-studio
  • android
cmake_minimum_required(VERSION 3.10.2)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)


#指明项目名称
project("myapplication" CXX)
#设置OpenCV_DIR路径
set(OpenCV_DIR "C:/Users/lenovo/Desktop/MyApplication/sdk/native/jni")
#于OpenCV_DIR路径下寻找OpenCV包
find_package(OpenCV REQUIRED )
#寻找".cpp" ".c"文件,将其设置为变量srcs
file(GLOB srcs "*.cpp" "*.c")
#寻找".hpp" ".h"文件,将其设置为变量hdrs
file(GLOB hdrs "*.hpp" "*.h")
#将路径"C:/Users/lenovo/Desktop/MyApplication/sdk/native/jni/include"设置为变量Opencv_INCLUDE_DIRS
set(Opencv_INCLUDE_DIRS "C:/Users/lenovo/Desktop/MyApplication/sdk/native/jni/include")
#将路径"C:/Users/lenovo/Desktop/oneTBB-master/include设置为变量TBB_PATH
set(TBB_PATH "C:/Users/lenovo/Desktop/oneTBB-master/include")
#指明头文件库
include_directories("${Opencv_INCLUDE_DIRS}")
include_directories("${TBB_PATH}")
#将搜索得到的".hpp" ".h" ".cpp" ".c"文件以及native-lib.cpp文件加入库"native-lib"
add_library(native-lib SHARED native-lib.cpp ${srcs} ${hdrs})
#找到log库,将其命名为"log_lib"
find_library(log-lib log)
#将库"log-lib","TBB_PATH","Opencv_INCLUDE_DIRS"链接到库"native-lib"
target_link_libraries(native-lib ${log-lib} ${TBB_PATH} ${Opencv_INCLUDE_DIRS})

 

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答