FindOpenCL.cmake 1.34 KB
Newer Older
1 2 3 4 5 6 7 8 9
# This script searches cl.h and cl.hpp (the C++ binding header). Grab these headers form http://www.khronos.org/registry/cl.
#
# The following variables will be filled:
#   * OPENCL_FOUND - if cl.h, cl.hpp and OpenCL lib was found
#   * OPENCL_INCLUDE_DIR - the path of cl.h if found
#   * OPENCL_CPP_INCLUDE_DIR - the path of cl.hpp if found
#   * OPENCL_LIBRARY - the path to the OpenCL library
#

10
FIND_PATH( OPENCL_INCLUDE_DIR CL/cl.h /usr/include /usr/local/include )
11
FIND_PATH( OPENCL_CPP_INCLUDE_DIR CL/cl.hpp /usr/include /usr/local/include )
12 13
FIND_LIBRARY( OPENCL_LIBRARY NAMES OpenCL PATH /usr/lib /usr/local/lib /usr/local/cuda/lib64 /usr/local/cuda/lib )

14 15
message( STATUS ${OPENCL_CPP_INCLUDE_DIR} )

16
SET( OPENCL_FOUND FALSE )
17 18 19
IF ( OPENCL_INCLUDE_DIR AND OPENCL_CPP_INCLUDE_DIR AND OPENCL_LIBRARY )
    SET( OPENCL_FOUND TRUE )
ENDIF ( OPENCL_INCLUDE_DIR AND OPENCL_CPP_INCLUDE_DIR AND OPENCL_LIBRARY )
20 21 22

IF ( OPENCL_FOUND )
   IF ( NOT OPENCL_FIND_QUIETLY )
23
       MESSAGE( STATUS "Found OpenCL: ${OPENCL_LIBRARY} and include in ${OPENCL_INCLUDE_DIR}" )
24 25 26
   ENDIF ( NOT OPENCL_FIND_QUIETLY )
ELSE ( OPENCL_FOUND )
   IF (OPENCL_FIND_REQUIRED)
27
      MESSAGE( FATAL_ERROR "Could not find OpenCL. Install an up-to-date graphics driver and grab the OpenCL headers from http://www.khronos.org/registry/cl." )
28 29
   ENDIF ( OPENCL_FIND_REQUIRED )
ENDIF ( OPENCL_FOUND )
30