CMake指定OpenCV版本

Posted 洪流之源

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMake指定OpenCV版本相关的知识,希望对你有一定的参考价值。

cmake_minimum_required(VERSION 3.4)

project(xxxx)

set(CMAKE_CXX_FLAGS "$CMAKE_CXX_FLAGS -g -O3 -std=c++11")

set(EXECUTABLE_OUTPUT_PATH $PROJECT_SOURCE_DIR/workspace/bin)

set(OpenCV_DIR opencv/lib/cmake/opencv4)
find_package(OpenCV 4.5 REQUIRED)
message(STATUS "OpenCV_DIR = $OpenCV_DIR")
message(STATUS "OpenCV_INCLUDE_DIRS = $OpenCV_INCLUDE_DIRS")
message(STATUS "OpenCV_LIBS = $OpenCV_LIBS")


set(OPENCV_LIBS
    opencv_core
    opencv_highgui
    opencv_imgproc
    opencv_imgcodecs
    opencv_video
    opencv_videoio
)


add_executable(pro  src/main.cpp)


target_link_libraries(
    pro
    $OPENCV_LIBS
)

以上是关于CMake指定OpenCV版本的主要内容,如果未能解决你的问题,请参考以下文章

OpenCV多版本管理

Ubuntu 18.04下Cmake指定OpenCV版本编译(针对问题:fatal error: opencv2/xfeatures2d.hpp: No such file or directory)

怎么使用CMake链接不同版本的第三方库

多版本opencv管理;find_package()的原理解析

opencv版本的问题

opencv系列之ubuntu系统下编译python版本的opencv(指定特定的ffmpeg)