本文主要是介绍cmake引入opencv和qt,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
cmake_minimum_required(VERSION 3.14)
project(CMake_demo LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
#设置opencv库目录
set(OpenCV_DIR "C:/opencv/build")
#自动寻找OpenCV依赖
find_package(OpenCV REQUIRED)
#包含头文件目录
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(CMake_demo
main.cpp
test.cpp
)
include_directories(test.h)
target_link_libraries(CMake_demo Qt${QT_VERSION_MAJOR}::Core)
#链接库文件,放到add_executable之后
target_link_libraries(CMake_demo ${OpenCV_LIBS})
这篇关于cmake引入opencv和qt的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!