title: CMake: How to implement version check in a config file?
body: <p>I Customize CMake package configure file <strong>OpenCLConfig.cmake</strong> for opencl-icd.</p>
  
  <p>refer to <a href="https://stackoverflow.com/questions/57680420/create-cmake-xxconfig-cmake-let-other-cmake-project-invoke?noredirect=1#">Create CMake XXConfig.cmake let other cmake project invoke</a></p>
  
  <p>Now, I encounter a problem: How to implement version check in a config file.</p>
  
  <p>I create <strong>OpenCLConfigVersion.cmake</strong> beside <strong>OpenCLConfig.cmake</strong>, which content is:</p>
  
  <pre><code>#OpenCLConfigVersion.cmake
  
  set(OpenCL_VERSION 2.2)
  set(OpenCL_VERSION_MAJOR 2)
  set(OpenCL_VERSION_MINOR 2)
  SET(OpenCV_VERSION_PATCH 0)
  SET(OpenCV_VERSION_TWEAK 0)
  </code></pre>
  
  <p>While I invoke it opencl-icd in others CMakeLists.txt, </p>
  
  <p>that is <code>find_package(OpenCL config)</code></p>
  
  <p>I got this error:</p>
  
  <pre><code>CMake Error at CMakeLists.txt:10 (find_package): Could not find a 
  configuration file for package "OpenCL" that is compatible with requested 
  version "2". The following configuration files were considered but not 
  accepted: C:/SDKs/ocl-icd/OpenCLConfig.cmake, version: unknown 
  </code></pre>
  
  <p>I have set <code>OpenCL_DIR</code> as <code>"C:/SDKs/ocl-icd"</code> in my CMakeLists.txt. </p>
  
  <p>My customized <strong>OpenCLConfig.cmake</strong> which content is</p>
  
  <pre><code>set(OpenCL_FOUND TRUE)
  set(OpenCL_ROOT_DIR "C:/SDKs/ocl-icd")
  
  set(OpenCL_VERSION 2.2)
  set(OpenCL_VERSION_MAJOR 2)
  set(OpenCL_VERSION_MINOR 2)
  SET(OpenCV_VERSION_PATCH 0)
  SET(OpenCV_VERSION_TWEAK 0)
  
  find_path(OpenCL_INCLUDE_DIR NAMES CL/cl.h PATHS "${OpenCL_ROOT_DIR}/include")
  set(OpenCL_INCLUDE_DIRS "${OpenCL_INCLUDE_DIR}")
  find_library(OpenCL_LIBRARY NAMES OpenCL.lib PATHS "${OpenCL_ROOT_DIR}/lib") 
  set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
  </code></pre>
  
  <p>How do I handle version problem.</p>