Ubuntu下QT使用CMake编译Opencv程序

àì夳堔傛蜴生んèń 2022-05-29 13:18 388阅读 0赞

今天搞opencv的环境配置学到了很多东西,这里主要记录Cmake编译Opencv过程中CMakeLists.txt的编写。
首先说明的是,这个是我从opencv的源码例程中摘出来的。

  1. # cmake needs this line
  2. cmake_minimum_required(VERSION 2.8) # 不用改
  3. # Define project name
  4. project(untitled) # untitled是工程名,使用时修改为自己建的工程的名字
  5. # Find OpenCV, you may need to set OpenCV_DIR variable
  6. find_package(OpenCV REQUIRED) # 不用改
  7. if(CMAKE_VERSION VERSION_LESS "2.8.11")
  8. # Add OpenCV headers location to your include paths
  9. include_directories(${OpenCV_INCLUDE_DIRS})
  10. endif()
  11. # Declare the executable target built from your sources
  12. add_executable(untitled main.cpp) # untitled是工程名,同上, main.cpp是对应的程序文件名
  13. # Link your application with OpenCV libraries
  14. target_link_libraries(untitled ${OpenCV_LIBS}) # untitled是工程名,同上

发表评论

表情:
评论列表 (有 0 条评论,388人围观)

还没有评论,来说两句吧...

相关阅读