summaryrefslogtreecommitdiff
path: root/cmake/Modules/FindOpenCL.cmake
diff options
context:
space:
mode:
authorCNugteren <web@cedricnugteren.nl>2015-05-30 12:30:43 +0200
committerCNugteren <web@cedricnugteren.nl>2015-05-30 12:30:43 +0200
commitbc5a341dfe591946e925db315fc7d8c0c25c2938 (patch)
treeb216ab5eee4863e3807d92b5ddd19fa22197ed22 /cmake/Modules/FindOpenCL.cmake
parentc7b054ea6747039f4405fd93da6e924f3e5c7f4b (diff)
Initial commit of preview version
Diffstat (limited to 'cmake/Modules/FindOpenCL.cmake')
-rw-r--r--cmake/Modules/FindOpenCL.cmake75
1 files changed, 75 insertions, 0 deletions
diff --git a/cmake/Modules/FindOpenCL.cmake b/cmake/Modules/FindOpenCL.cmake
new file mode 100644
index 00000000..2a4c583c
--- /dev/null
+++ b/cmake/Modules/FindOpenCL.cmake
@@ -0,0 +1,75 @@
+
+# ==================================================================================================
+# This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
+# project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
+# width of 100 characters per line.
+#
+# Author(s):
+# Cedric Nugteren <www.cedricnugteren.nl>
+#
+# ==================================================================================================
+#
+# Defines the following variables:
+# OPENCL_FOUND Boolean holding whether or not the OpenCL library was found
+# OPENCL_INCLUDE_DIRS The OpenCL include directory
+# OPENCL_LIBRARIES The OpenCL library
+#
+# In case OpenCL is not installed in the default directory, set the OPENCL_ROOT variable to point to
+# the root of OpenCL, such that 'OpenCL/cl.h' or 'CL/cl.h' can be found in $OPENCL_ROOT/include.
+# This can either be done using an environmental variable (e.g. export OPENCL_ROOT=/path/to/opencl)
+# or using a CMake variable (e.g. cmake -DOPENCL_ROOT=/path/to/opencl ..).
+#
+# ==================================================================================================
+
+# Sets the possible install locations
+set(OPENCL_HINTS
+ ${OPENCL_ROOT}
+ $ENV{OPENCL_ROOT}
+ $ENV{AMDAPPSDKROOT}
+ $ENV{CUDA_PATH}
+ $ENV{INTELOCLSDKROOT}
+ $ENV{NVSDKCOMPUTE_ROOT}
+ $ENV{ATISTREAMSDKROOT}
+)
+set(OPENCL_PATHS
+ /usr/local/cuda
+ /opt/cuda
+ /usr
+ /usr/local
+)
+
+# Finds the include directories
+find_path(OPENCL_INCLUDE_DIRS
+ NAMES OpenCL/cl.h CL/cl.h
+ HINTS ${OPENCL_HINTS}
+ PATH_SUFFIXES include OpenCL/common/inc inc include/x86_64 include/x64
+ PATHS ${OPENCL_PATHS}
+ DOC "OpenCL include header OpenCL/cl.h or CL/cl.h"
+)
+mark_as_advanced(OPENCL_INCLUDE_DIRS)
+
+# Finds the library
+find_library(OPENCL_LIBRARIES
+ NAMES OpenCL
+ HINTS ${OPENCL_HINTS}
+ PATH_SUFFIXES lib lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 OpenCL/common/lib/x64
+ PATHS ${OPENCL_PATHS}
+ DOC "OpenCL library"
+)
+mark_as_advanced(OPENCL_LIBRARIES)
+
+# ==================================================================================================
+
+# Notification messages
+if(NOT OPENCL_INCLUDE_DIRS)
+ message(STATUS "Could NOT find 'OpenCL/cl.h' or 'CL/cl.h', install OpenCL or set OPENCL_ROOT")
+endif()
+if(NOT OPENCL_LIBRARIES)
+ message(STATUS "Could NOT find OpenCL library, install it or set OPENCL_ROOT")
+endif()
+
+# Determines whether or not OpenCL was found
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(OpenCL DEFAULT_MSG OPENCL_INCLUDE_DIRS OPENCL_LIBRARIES)
+
+# ==================================================================================================