我为 opencl-icd 自定义 CMake 包配置文件OpenCLConfig.cmake。
参考Create CMake XXConfig.cmake let other cmake project invoke
现在,我遇到一个问题:如何在配置文件中实现版本检查。
我在OpenCLConfig.cmake旁边创建OpenCLConfigVersion.cmake,其内容是:
#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)
当我在其他 CMakeLists.txt 中调用它的 opencl-icd 时,
那是find_package(OpenCL config)
我收到了这个错误:
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
我已经在我的 CMakeLists.txt中设置OpenCL_DIR
了。"C:/SDKs/ocl-icd"
我自定义的 OpenCLConfig.cmake内容是
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})
如何处理版本问题。