老衛帶你學---clion上配置opencv時的cmakelists.txt
阿新 • • 發佈:2018-12-18
最近老衛在研究c++下的opencv,發現其配置cmakelists.txt有些麻煩,遂將此分享出來,供大家使用
cmake_minimum_required(VERSION 3.9) ##將其改為自己的版本號 project(opencv_test) ##改為自己的專案名稱 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") ##改為自己的c++版本號 # Where to find CMake modules and OpenCV set(OpenCV_DIR "D:\\opencv3.2\\opencv\\mingw-build") ##改為自己的opencv的build路徑,就是我們在cmake-gui中的輸出資料夾 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) add_executable(opencv_test main.cpp) ##改為自己的專案名稱 # add libs you need set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs) # linking target_link_libraries(opencv_test ${OpenCV_LIBS}) ##改為自己的專案名稱