[CMake] OpenCL Module?

Michael Wild themiwi at gmail.com
Mon Aug 29 10:05:43 EDT 2011


On Mon 29 Aug 2011 03:44:55 PM CEST, Michael Jackson wrote:
> Does anyone have an "FindOpenCL.cmake" file that they would like to share?
> ___________________________________________________________
> Mike Jackson                      www.bluequartz.net
> Principal Software Engineer       mike.jackson at bluequartz.net 
> BlueQuartz Software               Dayton, Ohio
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

Very simplistic, haven't tried it with all possible SDK's on all 
possible platforms (namely I only tried it on Ubuntu with 
nvidia-current-dev). In particular I'm not very happy with the 
PATH_SUFFIXES in the find_library, as this should probably be tailored 
to CMAKE_SIZEOF_VOID_P.

# - Find the OpenCL headers and library
#
# Defines the following if found:
#  OPENCL_FOUND        : TRUE if found, FALSE otherwise
#  OPENCL_INCLUDE_DIRS : Include directories for OpenCL
#  OPENCL_LIBRARIES    : The libraries to link against
#
# The user can set the OPENCLROOT environment variable to help finding 
OpenCL
# if it is installed in a non-standard place.

set(CMAKE_FIND_FRAMEWORK FIRST)

find_path(OPENCL_INCLUDE_DIR NAMES OpenCL/cl.h CL/cl.h PATHS
   ENV OPENCLROOT
   PATH_SUFFIXES include include/nvidia-current)

find_library(OPENCL_LIBRARY OpenCL PATHS
   ENV OPENCLROOT
   PATH_SUFFIXES lib/x86_64 lib/x64 lib/x86)

mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenCL OPENCL_INCLUDE_DIR 
OPENCL_LIBRARY)

set(OPENCL_INCLUDE_DIRS "${OPENCL_INCLUDE_DIR}")
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
#- EOF

HTH

Michael


More information about the CMake mailing list