Rely on find_package(OpenCL) (#18541)
This commit is contained in:
parent
82fe1677d0
commit
7b5acbb29a
42
thirdparty/dependencies.cmake
vendored
42
thirdparty/dependencies.cmake
vendored
@ -68,41 +68,15 @@ endif()
|
||||
|
||||
if(ENABLE_INTEL_GPU)
|
||||
if(ENABLE_SYSTEM_OPENCL)
|
||||
# try to find system OpenCL:
|
||||
# - 'brew install opencl-icd-loader'
|
||||
# - 'conan install opencl-icd-loader'
|
||||
find_package(OpenCLICDLoader QUIET)
|
||||
|
||||
if(OpenCLICDLoader_FOUND)
|
||||
# examples:
|
||||
# - 'brew install opencl-headers'
|
||||
# - 'conan install opencl-headers'
|
||||
find_package(OpenCLHeaders QUIET)
|
||||
if(NOT OpenCLHeaders_FOUND)
|
||||
message(WARNING "OpenCLHeaders not found, but OpenCLICDLoader is installed. Please, install OpenCL headers")
|
||||
else()
|
||||
set_property(TARGET OpenCL::OpenCL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenCL::Headers)
|
||||
endif()
|
||||
|
||||
# examples:
|
||||
# - 'brew install opencl-clhpp-headers'
|
||||
# - 'conan install opencl-clhpp-headers'
|
||||
find_package(OpenCLHeadersCpp QUIET)
|
||||
if(NOT OpenCLHeadersCpp_FOUND)
|
||||
message(WARNING "OpenCLHeadersCpp not found, but OpenCLICDLoader is installed. Please, install OpenCL C++ headers")
|
||||
else()
|
||||
get_target_property(opencl_cpp_include_dirs OpenCL::HeadersCpp INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set_property(TARGET OpenCL::OpenCL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenCL::HeadersCpp)
|
||||
endif()
|
||||
else()
|
||||
# try to find system OpenCL:
|
||||
# - 'apt-get install opencl-headers ocl-icd-opencl-dev'
|
||||
# - 'yum install ocl-icd-devel opencl-headers'
|
||||
# - 'conda install khronos-opencl-icd-loader -c conda-forge'
|
||||
# - 'vcpkg install opencl:<triplet>'
|
||||
# - 'conan install opencl-headers opencl-clhpp-headers opencl-icd-loader'
|
||||
# - 'brew install opencl-headers opencl-clhpp-headers opencl-icd-loader'
|
||||
find_package(OpenCL QUIET)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET OpenCL::OpenCL)
|
||||
# try to find CL/opencl.hpp
|
||||
@ -124,18 +98,6 @@ if(ENABLE_INTEL_GPU)
|
||||
set_target_properties(OpenCL::OpenCL PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "${opencl_interface_definitions}")
|
||||
endif()
|
||||
|
||||
# set variables for onednn_gpu
|
||||
if(OpenCLHeaders_FOUND)
|
||||
set(OpenCL_INCLUDE_DIR "$<TARGET_PROPERTY:OpenCL::Headers,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
set(OpenCL_LIBRARY "$<TARGET_PROPERTY:OpenCL::OpenCL,IMPORTED_LOCATION_RELEASE>")
|
||||
elseif(OpenCL_FOUND)
|
||||
# find_package(OpenCL) already defines OpenCL_INCLUDE_DIR and OpenCL_LIBRARY
|
||||
# see https://cmake.org/cmake/help/latest/module/FindOpenCL.html
|
||||
message(STATUS "Found OpenCL (ver. ${OpenCL_VERSION_STRING}, include dirs ${OpenCL_INCLUDE_DIRS})")
|
||||
else()
|
||||
message(FATAL_ERROR "Internal error: cannot find OpenCL headers")
|
||||
endif()
|
||||
else()
|
||||
add_subdirectory(thirdparty/ocl)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user