diff options
author | Gil Pitney <gil.pitney@linaro.org> | 2015-07-09 00:37:33 +0000 |
---|---|---|
committer | Gil Pitney <gil.pitney@linaro.org> | 2015-07-09 00:37:33 +0000 |
commit | f7d715248dc6e5e8224d1f161d61e551df111377 (patch) | |
tree | 41af925b175d19bf6dfbb8dce2ab46c1e3ad2860 /cmake/modules/FindOpenCLHeaders.cmake | |
parent | 670b0bf49d61dc33bcc08794572b0a3b592cb346 (diff) |
Implemented CMake check for opencl-headers minium version 1.2 installed
Previously, it was assumed the OpenCL headers version 1.2 were installed, and
if not, the build failed.
Now CMake will check this and error out before the build.
OpenCL header versions greater than 1.2 should also be acceptable.
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
Diffstat (limited to 'cmake/modules/FindOpenCLHeaders.cmake')
-rw-r--r-- | cmake/modules/FindOpenCLHeaders.cmake | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmake/modules/FindOpenCLHeaders.cmake b/cmake/modules/FindOpenCLHeaders.cmake new file mode 100644 index 0000000..6fafc79 --- /dev/null +++ b/cmake/modules/FindOpenCLHeaders.cmake @@ -0,0 +1,32 @@ +# FindOCLHeaders +# +# If successful, will define:: +# +# OCL_INCLUDE_DIR - Set to where CL/cl.h was found +# OCL_VERSION_STRING - Version of the OpenCL Headers "[Major].[minor]" +# + +include(CheckSymbolExists) +find_path(OCL_INCLUDE_DIR NAMES CL/cl.h PATHS /usr/include ) + +set(REQUIRED_VERSION "1_2") +if (${OCL_INCLUDE_DIR} STREQUAL "OCL_INCLUDE_DIR-NOTFOUND") + message(STATUS "Please install opencl-headers package for version ${REQUIRED_VERSION}") + message(FATAL_ERROR "ERROR: Unable to find installed OpenCL Headers") +endif() + +set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") + +CHECK_SYMBOL_EXISTS(CL_VERSION_${REQUIRED_VERSION} "${OCL_INCLUDE_DIR}/CL/cl.h" + OPENCL_VERSION_${VERSION}) + +if(OPENCL_VERSION_${VERSION}) + string(REPLACE "_" "." REQUIRED_VERSION "${REQUIRED_VERSION}") + set(OCL_VERSION_STRING ${REQUIRED_VERSION} ) +endif() + +MESSAGE(STATUS "OpenCL Headers: Path: ${OCL_INCLUDE_DIR}; Version: ${OCL_VERSION_STRING}") + +if ("${OCL_VERSION_STRING}" STREQUAL "" OR NOT "${OCL_VERSION_STRING}" STREQUAL "${REQUIRED_VERSION}") + message(FATAL_ERROR "ERROR: expected OpenCL Headers version ${REQUIRED_VERSION}") +endif() |