1. find_package(OpenCV 3 REQUIRED)
通过OpenCV_DIR变量寻找OpenCVConfig.cmake文件,默认在/usr/share/OpenCV中
set(OpenCV_DIR "***********************")指定find_package()搜索opencv路径,用于不同opencv版本切换。
2,OpenCVConfig.cmake
其中描述了cmakelist.txt中引用opencv的方式。
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11
target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS})
文件定义了很多关于cmakelist.txt中常用的变量
如:OpenCV_LIBS, OpenCV_INCLUDE_DIRS等
# ==================================================================