cmake使用指定版本opencv

方法1:让cmake找到opencv的OpenCVConfig.cmake文件,比如

set(OpenCV_DIR "/usr/local/opencv3.4.2/share/OpenCV")  #OpenCVConfig.cmake所在的文件目录
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(orb orb.cpp)
target_link_libraries(orb ${OpenCV_LIBS})

方法2:直接指定头文件目录

set(OpenCV_INCLUDE_DIRS "/usr/local/opencv3.4.2/include")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(orb orb.cpp)
target_link_libraries(orb ${OpenCV_LIBS})

 

你可能感兴趣的:(cmake,opencv,C++)