Ubuntu下QT使用CMake编译Opencv程序
今天搞opencv的环境配置学到了很多东西,这里主要记录Cmake编译Opencv过程中CMakeLists.txt的编写。
首先说明的是,这个是我从opencv的源码例程中摘出来的。
# cmake needs this line
cmake_minimum_required(VERSION 2.8) # 不用改
# Define project name
project(untitled) # untitled是工程名,使用时修改为自己建的工程的名字
# Find OpenCV, you may need to set OpenCV_DIR variable
find_package(OpenCV REQUIRED) # 不用改
if(CMAKE_VERSION VERSION_LESS "2.8.11")
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
endif()
# Declare the executable target built from your sources
add_executable(untitled main.cpp) # untitled是工程名,同上, main.cpp是对应的程序文件名
# Link your application with OpenCV libraries
target_link_libraries(untitled ${OpenCV_LIBS}) # untitled是工程名,同上
还没有评论,来说两句吧...