2 # This module tries to find an OpenCL implementation on your system. It supports
3 # AMD / ATI, Apple and NVIDIA implementations, but should work, too.
5 # To set manually the paths, define these environment variables:
6 # OpenCL_INCPATH - Include path (e.g. OpenCL_INCPATH=/opt/cuda/4.0/cuda/include)
7 # OpenCL_LIBPATH - Library path (e.h. OpenCL_LIBPATH=/usr/lib64/nvidia)
9 # Once done this will define
10 # OPENCL_FOUND - system has OpenCL
11 # OPENCL_INCLUDE_DIRS - the OpenCL include directory
12 # OPENCL_LIBRARIES - link these to use OpenCL
14 # WIN32 should work, but is untested
16 FIND_PACKAGE(PackageHandleStandardArgs)
18 SET (OPENCL_VERSION_STRING "0.1.0")
19 SET(OPENCL_VERSION_MAJOR 0)
20 SET(OPENCL_VERSION_MINOR 1)
21 SET(OPENCL_VERSION_PATCH 0)
25 FIND_LIBRARY(OPENCL_LIBRARIES OpenCL DOC "OpenCL lib for OSX")
26 FIND_PATH(OPENCL_INCLUDE_DIRS OpenCL/cl.h DOC "Include for OpenCL on OSX")
27 FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS OpenCL/cl.hpp DOC "Include for OpenCL CPP bindings on OSX")
32 FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h)
33 FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp)
35 IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
36 SET(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86_64
")
37 if(NOT IS_DIRECTORY ${OPENCL_LIB_DIR})
38 SET(OPENCL_LIB_DIR "$ENV{CUDA_PATH}/lib/x64
")
41 SET(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86
")
42 if(NOT IS_DIRECTORY ${OPENCL_LIB_DIR}) # need to convert path in the cmake style ?
43 SET(OPENCL_LIB_DIR "$ENV{CUDA_PATH}/lib/Win32
")
46 file(TO_CMAKE_PATH ${OPENCL_LIB_DIR} OPENCL_LIB_DIR)
47 GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIB_DIR} ABSOLUTE)
49 FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib PATHS ${OPENCL_LIB_DIR} ENV OpenCL_LIBPATH)
51 GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
53 # On Win32 search relative to the library
54 FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}
" ENV OpenCL_INCPATH)
55 FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}
" ENV OpenCL_INCPATH)
59 # Unix style platforms
60 FIND_LIBRARY(OPENCL_LIBRARIES OpenCL
61 PATHS ENV LD_LIBRARY_PATH ENV OpenCL_LIBPATH
64 GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH)
65 GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
67 # The AMD SDK currently does not place its headers
68 # in /usr/include, therefore also search relative
70 FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include
" "/opt/AMDAPP/include
" ENV OpenCL_INCPATH)
71 FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include
" "/opt/AMDAPP/include
" ENV OpenCL_INCPATH)
77 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS)
79 IF(_OPENCL_CPP_INCLUDE_DIRS)
80 SET( OPENCL_HAS_CPP_BINDINGS TRUE )
81 LIST( APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS} )
82 # This is often the same, so clean up
83 LIST( REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS )
84 ENDIF(_OPENCL_CPP_INCLUDE_DIRS)