熟悉 CMake (三)—— 配置 opencv3

对 opencv 3 的配置十分简单,只需修改 CMakeLists.txt 文件:

在最后一行 add_executable 前后插入如下内容:

  • find_package(OpenCV REQUIRED)
  • target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

这里不防给出一个完整 CMakeLists.txt 文件:

cmake_minimum_required(VERSION 3.5)
project(OpenCV_Test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
find_package(OpenCV REQUIRED)
add_executable(OpenCV_Test ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

你可能感兴趣的:(CMake)