2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# Copyright 2013 Pixar
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
# with the following modification; you may not use this file except in
|
|
|
|
# compliance with the Apache License and the following modification to it:
|
|
|
|
# Section 6. Trademarks. is deleted and replaced with:
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
# names, trademarks, service marks, or product names of the Licensor
|
|
|
|
# and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
# the License and to reproduce the content of the NOTICE file.
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# You may obtain a copy of the Apache License at
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the Apache License with the above modification is
|
|
|
|
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the Apache License for the specific
|
|
|
|
# language governing permissions and limitations under the Apache License.
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# - Try to find an OpenCL library
|
|
|
|
# Once done this will define
|
|
|
|
#
|
|
|
|
# OPENCL_FOUND - System has OPENCL
|
2013-03-17 01:38:17 +00:00
|
|
|
# OPENCL_INCLUDE_DIRS - The OPENCL include directory
|
2012-06-08 18:18:20 +00:00
|
|
|
# OPENCL_LIBRARIES - The libraries needed to use OPENCL
|
|
|
|
|
|
|
|
|
2012-06-16 23:03:52 +00:00
|
|
|
find_package(PackageHandleStandardArgs)
|
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_library( OPENCL_LIBRARIES
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
OpenCL
|
2012-06-16 23:03:52 +00:00
|
|
|
DOC "OpenCL lib for OSX"
|
|
|
|
)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( OPENCL_INCLUDE_DIRS
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
OpenCL/cl.h
|
2012-06-16 23:03:52 +00:00
|
|
|
DOC "Include for OpenCL on OSX"
|
|
|
|
)
|
|
|
|
|
|
|
|
find_path( _OPENCL_CPP_INCLUDE_DIRS
|
2012-08-04 02:51:27 +00:00
|
|
|
NAMES
|
|
|
|
OpenCL/cl.hpp
|
2012-06-16 23:03:52 +00:00
|
|
|
DOC "Include for OpenCL CPP bindings on OSX"
|
|
|
|
)
|
|
|
|
|
|
|
|
elseif (WIN32)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( OPENCL_INCLUDE_DIRS
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
CL/cl.h
|
2012-06-16 23:03:52 +00:00
|
|
|
)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( _OPENCL_CPP_INCLUDE_DIRS
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
|
|
|
CL/cl.hpp
|
|
|
|
)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_library( OPENCL_LIBRARIES
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
OpenCL.lib
|
|
|
|
PATHS
|
2012-06-16 23:03:52 +00:00
|
|
|
ENV OpenCL_LIBPATH
|
2012-12-11 20:14:30 +00:00
|
|
|
"$ENV{ATISTREAMSDKROOT}/lib/x86_64"
|
|
|
|
"$ENV{ATISTREAMSDKROOT}/lib/x86"
|
|
|
|
"C:/Program Files (x86)/Intel/OpenCL SDK/2.0/lib/x64"
|
|
|
|
"C:/Program Files (x86)/Intel/OpenCL SDK/2.0/lib/x86"
|
2012-06-16 23:03:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
get_filename_component( _OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE )
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( OPENCL_INCLUDE_DIRS
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
CL/cl.h
|
|
|
|
PATHS
|
|
|
|
"${_OPENCL_INC_CAND}"
|
2012-06-16 23:03:52 +00:00
|
|
|
ENV OpenCL_INCPATH
|
|
|
|
)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( _OPENCL_CPP_INCLUDE_DIRS
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
CL/cl.hpp
|
|
|
|
PATHS
|
|
|
|
"${_OPENCL_INC_CAND}"
|
2012-06-16 23:03:52 +00:00
|
|
|
ENV OpenCL_INCPATH
|
|
|
|
)
|
|
|
|
|
2015-06-02 23:20:41 +00:00
|
|
|
# AMD APP SDK
|
|
|
|
find_file(_OPENCL_DX_INTEROP_CL_D3D11_H
|
|
|
|
NAMES
|
|
|
|
CL/cl_d3d11.h
|
|
|
|
PATHS
|
|
|
|
"${_OPENCL_INC_CAND}"
|
|
|
|
"${OPENCL_INCLUDE_DIRS}"
|
|
|
|
ENV OpenCL_INCPATH
|
|
|
|
)
|
|
|
|
if (_OPENCL_DX_INTEROP_CL_D3D11_H)
|
|
|
|
set(OPENCL_CL_D3D11_H_FOUND "YES")
|
|
|
|
message("OpenCL DX11 interop found ${_OPENCL_DX_INTEROP_CL_D3D11_H}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# NVIDIA GPU Computing ToolKit
|
|
|
|
find_file(_OPENCL_DX_INTEROP_CL_D3D11_EXT_H
|
|
|
|
NAMES
|
|
|
|
CL/cl_d3d11_ext.h
|
|
|
|
PATHS
|
|
|
|
"${_OPENCL_INC_CAND}"
|
|
|
|
"${OPENCL_INCLUDE_DIRS}"
|
|
|
|
ENV OpenCL_INCPATH
|
|
|
|
)
|
|
|
|
|
|
|
|
if (_OPENCL_DX_INTEROP_CL_D3D11_EXT_H)
|
|
|
|
set(OPENCL_CL_D3D11_EXT_H_FOUND "YES")
|
|
|
|
message("OpenCL DX11 interop found ${_OPENCL_DX_INTEROP_CL_D3D11_EXT_H}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT _OPENCL_DX_INTEROP_CL_D3D11_H AND NOT _OPENCL_DX_INTEROP_CL_D3D11_EXT_H)
|
|
|
|
message("OpenCL DX11 interop not found")
|
|
|
|
endif()
|
|
|
|
|
2012-06-16 23:03:52 +00:00
|
|
|
elseif (UNIX)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_library( OPENCL_LIBRARIES
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
|
|
|
OpenCL
|
2012-08-04 02:51:27 +00:00
|
|
|
PATHS
|
|
|
|
ENV LD_LIBRARY_PATH
|
2012-06-16 23:03:52 +00:00
|
|
|
ENV OpenCL_LIBPATH
|
|
|
|
)
|
|
|
|
|
|
|
|
get_filename_component( OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH )
|
|
|
|
|
2014-04-09 20:43:38 +00:00
|
|
|
get_filename_component( _OPENCL_INC_CAND "${OPENCL_LIB_DIR}/../../include" ABSOLUTE )
|
2012-06-16 23:03:52 +00:00
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( OPENCL_INCLUDE_DIRS
|
|
|
|
NAMES
|
|
|
|
CL/cl.h
|
|
|
|
PATHS
|
2014-04-09 20:43:38 +00:00
|
|
|
"${_OPENCL_INC_CAND}"
|
2012-08-04 02:51:27 +00:00
|
|
|
"/usr/local/cuda/include"
|
|
|
|
"/opt/AMDAPP/include"
|
2012-06-16 23:03:52 +00:00
|
|
|
ENV OpenCL_INCPATH
|
|
|
|
)
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
find_path( _OPENCL_CPP_INCLUDE_DIRS
|
2012-06-16 23:03:52 +00:00
|
|
|
NAMES
|
2012-08-04 02:51:27 +00:00
|
|
|
CL/cl.hpp
|
|
|
|
PATHS
|
2014-04-09 20:43:38 +00:00
|
|
|
"${_OPENCL_INC_CAND}"
|
2012-08-04 02:51:27 +00:00
|
|
|
"/usr/local/cuda/include"
|
|
|
|
"/opt/AMDAPP/include"
|
2012-06-16 23:03:52 +00:00
|
|
|
ENV OpenCL_INCPATH
|
|
|
|
)
|
|
|
|
|
|
|
|
else ()
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
message( "Could not determine OpenCL platform" )
|
2012-06-16 23:03:52 +00:00
|
|
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
|
|
if(_OPENCL_CPP_INCLUDE_DIRS)
|
|
|
|
|
|
|
|
set( OPENCL_HAS_CPP_BINDINGS TRUE )
|
|
|
|
|
|
|
|
list( APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS} )
|
|
|
|
|
|
|
|
list( REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS )
|
2013-01-31 23:34:35 +00:00
|
|
|
|
|
|
|
if(EXISTS "${OPENCL_INCLUDE_DIRS}/CL/cl.h")
|
|
|
|
|
|
|
|
file(STRINGS "${OPENCL_INCLUDE_DIRS}/CL/cl.h" LINES REGEX "^#define CL_VERSION_.*$")
|
|
|
|
|
|
|
|
foreach(LINE ${LINES})
|
|
|
|
|
|
|
|
string(REGEX MATCHALL "[0-9]+" VERSION ${LINE})
|
|
|
|
|
|
|
|
#string(SUBSTRING ${VERSION} 1 2 FOO)
|
|
|
|
|
|
|
|
list(GET VERSION 0 MAJOR)
|
|
|
|
list(GET VERSION 1 MINOR)
|
|
|
|
set(VERSION ${MAJOR}.${MINOR})
|
|
|
|
|
|
|
|
if (NOT OPENCL_VERSION OR OPENCL_VERSION VERSION_LESS ${VERSION})
|
|
|
|
set(OPENCL_VERSION ${VERSION})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
endif()
|
2012-06-16 23:03:52 +00:00
|
|
|
|
|
|
|
endif(_OPENCL_CPP_INCLUDE_DIRS)
|
|
|
|
|
2013-01-31 23:34:35 +00:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
|
|
|
find_package_handle_standard_args(OpenCL
|
|
|
|
REQUIRED_VARS
|
|
|
|
OPENCL_LIBRARIES
|
|
|
|
OPENCL_INCLUDE_DIRS
|
|
|
|
VERSION_VAR
|
|
|
|
OPENCL_VERSION
|
|
|
|
)
|
|
|
|
|
2012-06-16 23:03:52 +00:00
|
|
|
mark_as_advanced( OPENCL_INCLUDE_DIRS )
|