FindOpenCL
Added in version 3.1.
Finds Open Computing Language (OpenCL):
find_package(OpenCL [<version>] [...])
OpenCL is a framework for writing programs that execute across heterogeneous platforms, such as CPUs, GPUs, and other accelerators.
Added in version 3.24: Detection of OpenCL 3.0.
Added in version 3.10: Detection of OpenCL 2.1 and 2.2.
Imported Targets
This module provides the following Imported Targets:
-
OpenCL::OpenCL -
Added in version 3.7.
Target encapsulating the OpenCL usage requirements, available if OpenCL has been found.
Result Variables
This module defines the following variables:
-
OpenCL_FOUND -
Boolean indicating whether (the requested version of) OpenCL was found.
-
OpenCL_VERSION -
Added in version 4.2.
Highest supported OpenCL version found in form of
<major>.<minor>(e.g.,1.2). -
OpenCL_VERSION_MAJOR -
The major version of the OpenCL implementation.
-
OpenCL_VERSION_MINOR -
The minor version of the OpenCL implementation.
-
OpenCL_INCLUDE_DIRS -
Include directories needed to use OpenCL.
-
OpenCL_LIBRARIES -
Libraries needed to link to OpenCL.
Cache Variables
The following cache variables may also be set:
-
OpenCL_INCLUDE_DIR -
The OpenCL include directory.
-
OpenCL_LIBRARY -
The path to the OpenCL library.
Deprecated Variables
The following variables are provided for backward compatibility:
-
OpenCL_VERSION_STRING -
Deprecated since version 4.2: Use
OpenCL_VERSION, which has the same value.Highest supported OpenCL version found in form of
<major>.<minor>.
Examples
Finding OpenCL and linking it to a project target:
find_package(OpenCL) target_link_libraries(project_target PRIVATE OpenCL::OpenCL)
© 2000–2026 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/latest/module/FindOpenCL.html