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

cmake finds incorrect OpenCV #524

Open
navid-mahmoudian opened this issue Feb 17, 2021 · 0 comments
Open

cmake finds incorrect OpenCV #524

navid-mahmoudian opened this issue Feb 17, 2021 · 0 comments

Comments

@navid-mahmoudian
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant