opencv/cmake/OpenCVDetectOpenCL.cmake

85 lines
2.5 KiB
CMake
Raw Normal View History

set(OPENCL_FOUND ON CACHE BOOL "OpenCL library is found")
if(APPLE)
2013-03-16 03:29:22 +08:00
set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
set(OPENCL_INCLUDE_DIR "" CACHE PATH "OpenCL include directory")
Merge pull request #13972 from Mainvooid:add_cuda_support_for_D3D11_interop * Add CUDA support for D3D11 interop. #13888 color_detail.hpp: fixed build error : dynamic initialization is not supported for a __constant__ variable. directx.cpp: Add CUDA support(cl_nv_d3d11_sharing) for D3D11 interop. #13888 Update directx.cpp Format adjustment. Update directx.cpp fix error. Update directx.cpp Format adjustment Update directx.cpp fix trailing whitespace. fix format errors convert indentation to spaces . Trim trailing whitespace. Add information about source of cl_d3d11_ext.h Avoid unrelated changes. Increase compile-time conditional judgment. Increase the judgment of whether the OCL device has the required extensions at compile time. Add compilation option `HAVE_CLNVEXT`.Check CL support in runtime. Check result of `clGetExtensionFunctionAddressForPlatform` for KHR is invalid.It always can get the address(from OpenCL.dll),So I check NV support(from nvopencl64.dll) before KHR when `HAVE_CLNVEXT` is enabled. Delete cl_d3d11_ext.h Modified parameter list fix "cannot open include file: 'CL/cl_d3d11_ext.h'" remove not referenced var fix C2143: syntax error Improve compile-time judgment. dlrectx.cpp Modify the detection order. initializeContextFromD3D11Device: ``` // try with NV(Need to check it first) // try with KHR ``` fix warnig C4100 Revert "fix warnig C4100" This reverts commit 76e5becb67780071d0cbde61cc4f5f807ad7c5ac. fix warning C4100 fix warning C4505 Format alignment Format adjustment and automatically detect header files. Automatically detect header files when users are not configured or configuration errors occur. avoid unrelated changes. Update .cmake Update .cmake * fix build errors * fix warning:defined but not used * Revert "fix warning:defined but not used" This reverts commit 7ab3537cd070f89b15bc2926e4ac9ec74c84a122. * fix warning:defined but not used * fix build error for mac * fix build error for win * optimizing branch judgment * Revert "optimizing branch judgment" This reverts commit 88b72b870ec13fd26f64a5ac374484c5cfe80854. * fix warning C4702: unreachable code * remove unused code * Fix problems that may lead to undefined behavior * Add status check * fix error C2664,C2665 : cannot convert argument * Format adjustment VSCODE will automatically format the indentation to 4 spaces in some situation. * fix error C2440 * fix error C2440 * add cl_d3d11_ext.h * Format adjustment * remove unnecessary checks
2019-03-24 23:34:09 +08:00
else()
set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library")
set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory")
ocv_install_3rdparty_licenses(opencl-headers "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/LICENSE.txt")
Merge pull request #13972 from Mainvooid:add_cuda_support_for_D3D11_interop * Add CUDA support for D3D11 interop. #13888 color_detail.hpp: fixed build error : dynamic initialization is not supported for a __constant__ variable. directx.cpp: Add CUDA support(cl_nv_d3d11_sharing) for D3D11 interop. #13888 Update directx.cpp Format adjustment. Update directx.cpp fix error. Update directx.cpp Format adjustment Update directx.cpp fix trailing whitespace. fix format errors convert indentation to spaces . Trim trailing whitespace. Add information about source of cl_d3d11_ext.h Avoid unrelated changes. Increase compile-time conditional judgment. Increase the judgment of whether the OCL device has the required extensions at compile time. Add compilation option `HAVE_CLNVEXT`.Check CL support in runtime. Check result of `clGetExtensionFunctionAddressForPlatform` for KHR is invalid.It always can get the address(from OpenCL.dll),So I check NV support(from nvopencl64.dll) before KHR when `HAVE_CLNVEXT` is enabled. Delete cl_d3d11_ext.h Modified parameter list fix "cannot open include file: 'CL/cl_d3d11_ext.h'" remove not referenced var fix C2143: syntax error Improve compile-time judgment. dlrectx.cpp Modify the detection order. initializeContextFromD3D11Device: ``` // try with NV(Need to check it first) // try with KHR ``` fix warnig C4100 Revert "fix warnig C4100" This reverts commit 76e5becb67780071d0cbde61cc4f5f807ad7c5ac. fix warning C4100 fix warning C4505 Format alignment Format adjustment and automatically detect header files. Automatically detect header files when users are not configured or configuration errors occur. avoid unrelated changes. Update .cmake Update .cmake * fix build errors * fix warning:defined but not used * Revert "fix warning:defined but not used" This reverts commit 7ab3537cd070f89b15bc2926e4ac9ec74c84a122. * fix warning:defined but not used * fix build error for mac * fix build error for win * optimizing branch judgment * Revert "optimizing branch judgment" This reverts commit 88b72b870ec13fd26f64a5ac374484c5cfe80854. * fix warning C4702: unreachable code * remove unused code * Fix problems that may lead to undefined behavior * Add status check * fix error C2664,C2665 : cannot convert argument * Format adjustment VSCODE will automatically format the indentation to 4 spaces in some situation. * fix error C2440 * fix error C2440 * add cl_d3d11_ext.h * Format adjustment * remove unnecessary checks
2019-03-24 23:34:09 +08:00
endif()
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
2013-03-16 03:29:22 +08:00
if(OPENCL_FOUND)
Merge pull request #13972 from Mainvooid:add_cuda_support_for_D3D11_interop * Add CUDA support for D3D11 interop. #13888 color_detail.hpp: fixed build error : dynamic initialization is not supported for a __constant__ variable. directx.cpp: Add CUDA support(cl_nv_d3d11_sharing) for D3D11 interop. #13888 Update directx.cpp Format adjustment. Update directx.cpp fix error. Update directx.cpp Format adjustment Update directx.cpp fix trailing whitespace. fix format errors convert indentation to spaces . Trim trailing whitespace. Add information about source of cl_d3d11_ext.h Avoid unrelated changes. Increase compile-time conditional judgment. Increase the judgment of whether the OCL device has the required extensions at compile time. Add compilation option `HAVE_CLNVEXT`.Check CL support in runtime. Check result of `clGetExtensionFunctionAddressForPlatform` for KHR is invalid.It always can get the address(from OpenCL.dll),So I check NV support(from nvopencl64.dll) before KHR when `HAVE_CLNVEXT` is enabled. Delete cl_d3d11_ext.h Modified parameter list fix "cannot open include file: 'CL/cl_d3d11_ext.h'" remove not referenced var fix C2143: syntax error Improve compile-time judgment. dlrectx.cpp Modify the detection order. initializeContextFromD3D11Device: ``` // try with NV(Need to check it first) // try with KHR ``` fix warnig C4100 Revert "fix warnig C4100" This reverts commit 76e5becb67780071d0cbde61cc4f5f807ad7c5ac. fix warning C4100 fix warning C4505 Format alignment Format adjustment and automatically detect header files. Automatically detect header files when users are not configured or configuration errors occur. avoid unrelated changes. Update .cmake Update .cmake * fix build errors * fix warning:defined but not used * Revert "fix warning:defined but not used" This reverts commit 7ab3537cd070f89b15bc2926e4ac9ec74c84a122. * fix warning:defined but not used * fix build error for mac * fix build error for win * optimizing branch judgment * Revert "optimizing branch judgment" This reverts commit 88b72b870ec13fd26f64a5ac374484c5cfe80854. * fix warning C4702: unreachable code * remove unused code * Fix problems that may lead to undefined behavior * Add status check * fix error C2664,C2665 : cannot convert argument * Format adjustment VSCODE will automatically format the indentation to 4 spaces in some situation. * fix error C2440 * fix error C2440 * add cl_d3d11_ext.h * Format adjustment * remove unnecessary checks
2019-03-24 23:34:09 +08:00
if(OPENCL_LIBRARY)
set(HAVE_OPENCL_STATIC ON)
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
else()
set(HAVE_OPENCL_STATIC OFF)
endif()
if(NOT HAVE_OPENCL_STATIC)
try_compile(__VALID_OPENCL
"${OpenCV_BINARY_DIR}"
"${OpenCV_SOURCE_DIR}/cmake/checks/opencl.cpp"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
OUTPUT_VARIABLE TRY_OUT
)
if(NOT TRY_OUT MATCHES "OpenCL is valid")
message(WARNING "Can't use OpenCL")
return()
endif()
2013-03-16 03:29:22 +08:00
endif()
set(HAVE_OPENCL 1)
2015-01-02 08:33:40 +08:00
if(WITH_OPENCL_SVM)
set(HAVE_OPENCL_SVM 1)
endif()
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
2013-03-16 03:29:22 +08:00
if(WITH_OPENCLAMDFFT)
find_path(CLAMDFFT_ROOT_DIR
NAMES include/clAmdFft.h
PATHS ENV CLAMDFFT_PATH ENV ProgramFiles
PATH_SUFFIXES clAmdFft AMD/clAmdFft
DOC "AMD FFT root directory"
NO_DEFAULT_PATH)
find_path(CLAMDFFT_INCLUDE_DIR
2013-03-16 03:29:22 +08:00
NAMES clAmdFft.h
HINTS ${CLAMDFFT_ROOT_DIR}
PATH_SUFFIXES include
DOC "clAmdFft include directory")
if(CLAMDFFT_INCLUDE_DIR)
2013-03-16 03:29:22 +08:00
set(HAVE_CLAMDFFT 1)
list(APPEND OPENCL_INCLUDE_DIRS "${CLAMDFFT_INCLUDE_DIR}")
endif()
endif()
2012-10-17 07:18:30 +08:00
2013-03-16 03:29:22 +08:00
if(WITH_OPENCLAMDBLAS)
find_path(CLAMDBLAS_ROOT_DIR
NAMES include/clAmdBlas.h
PATHS ENV CLAMDBLAS_PATH ENV ProgramFiles
2013-03-16 03:29:22 +08:00
PATH_SUFFIXES clAmdBlas AMD/clAmdBlas
DOC "AMD FFT root directory"
NO_DEFAULT_PATH)
2012-10-17 07:18:30 +08:00
2013-03-16 03:29:22 +08:00
find_path(CLAMDBLAS_INCLUDE_DIR
NAMES clAmdBlas.h
HINTS ${CLAMDBLAS_ROOT_DIR}
PATH_SUFFIXES include
DOC "clAmdFft include directory")
if(CLAMDBLAS_INCLUDE_DIR)
2013-03-16 03:29:22 +08:00
set(HAVE_CLAMDBLAS 1)
list(APPEND OPENCL_INCLUDE_DIRS "${CLAMDBLAS_INCLUDE_DIR}")
endif()
endif()
# check WITH_OPENCL_D3D11_NV is located in OpenCVDetectDirectX.cmake file
endif()