Skip to content
This repository was archived by the owner on Feb 25, 2021. It is now read-only.
This repository was archived by the owner on Feb 25, 2021. It is now read-only.

cmake finds incorrect OpenCV #524

@navid-mahmoudian

Description

@navid-mahmoudian

Hello,
Thank you for providing this very nice library. I have several versions of OpenCV on my computer (3.4.10, 4.3.0, 4.5.1). I want to force the CMake to use OpenCV 4.5.1. For that, I set the OpenCV_DIR to point to the place that OpenCVConfog.cmake exists, but the CMake finds the path related to the older OpenCV 3.4.10 version. I think it is because in your CMakeLists.txt you first check for find_package(OpenCV 3.3.1 QUIET ) and since it already finds version 3.4, it works with this older version. I changed the following part in your CMakeLists.txt


find_package(OpenCV 3.3.1 QUIET
             COMPONENTS
             core imgcodecs videoio features2d calib3d highgui)
if(NOT OpenCV_FOUND)
    find_package(OpenCV 4.0 REQUIRED
                 COMPONENTS
                 core imgcodecs videoio features2d calib3d highgui)
    if(NOT OpenCV_FOUND)
        message(FATAL_ERROR "OpenCV >= 3.3.1 not found")
    endif()
endif()
message(STATUS "Use OpenCV ${OpenCV_VERSION}")

to


find_package(OpenCV REQUIRED
             COMPONENTS
             core imgcodecs videoio features2d calib3d highgui)
message(STATUS "Use OpenCV ${OpenCV_VERSION}")

and now the CMake works perfectly. If you accept this solution, I can make a pull request and also add a version control at the end of the above code to have OpenCV >= 3.3.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions