Properly check for version in find_package

If I ask for version 2, the current trunk version (version 3), will say it is compatible, which is erroneous.

Do not consider different major versions compatible in cmake config file
pull/5829/head
Vincent Rabaud 9 years ago committed by Maksim Shabunin
parent 437fbe2594
commit 932043fdc2
  1. 3
      cmake/templates/OpenCVConfig-version.cmake.in
  2. 1
      cmake/templates/OpenCVConfig.cmake.in

@ -9,6 +9,7 @@ if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE True) set(PACKAGE_VERSION_COMPATIBLE True)
endif() endif()
if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) if(PACKAGE_FIND_VERSION_MAJOR EQUAL @OPENCV_VERSION_MAJOR@
AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE True) set(PACKAGE_VERSION_COMPATIBLE True)
endif() endif()

@ -110,6 +110,7 @@ set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@) set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@)
# Extract the directory where *this* file has been installed (determined at cmake run-time) # Extract the directory where *this* file has been installed (determined at cmake run-time)
unset(OpenCV_CONFIG_PATH CACHE)
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)
if(NOT WIN32 OR ANDROID) if(NOT WIN32 OR ANDROID)

Loading…
Cancel
Save