Reputation: 15009
There is the standard CMake command:
find_package(OpenCV REQUIRED)
When both v2 and v3 are installed, v3 will be chosen.
Now, due to various issues, I want to use OpenCV v2 if available, but if not, fall forward to OpenCV v3. Unfortunately this is not a valid keyword:
find_package(OpenCV 2 AT_LEAST)
One solution might be:
find_package(OpenCV 2 REQUIRED)
if (NOT OpenCV_FOUND)
find_package(OpenCV 3 REQUIRED)
endif()
Is there a better way?
Upvotes: 1
Views: 184
Reputation: 5714
Some based on your solution
find_package(OpenCV 2 EXACT QUIET)
if (NOT OpenCV_FOUND)
message(STATUS "OpenCV v2 not found. Trying to find OpenCV v3")
find_package(OpenCV 3 REQUIRED)
endif()
Upvotes: 2