CMakeLists.txt我用於OpenCV應用程序配置。
cmake_minimum_required(VERSION 2.8)
set (PROJ_NAME YourAppName)
project(${PROJ_NAME})
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
FIND_PACKAGE(OpenCV)
set(folder_source main.cpp
)
set(folder_header main.h
)
SOURCE_GROUP("Source Files" FILES ${folder_source})
SOURCE_GROUP("Header Files" FILES ${folder_header})
ADD_EXECUTABLE(${PROJ_NAME} ${folder_source} ${folder_header})
TARGET_LINK_LIBRARIES(${PROJ_NAME} ${OpenCV_LIBS})
它工作正常,但檢查你的OpenCV的路徑不包含空格
(它不喜歡,如 「C:/文檔/ Visual Studio中2015 /項目/ opencv_build」 路徑)。