OpenCVDetectOpenCL.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. set(OPENCL_FOUND ON CACHE BOOL "OpenCL library is found")
  2. if(APPLE)
  3. set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
  4. set(OPENCL_INCLUDE_DIR "" CACHE PATH "OpenCL include directory")
  5. else()
  6. set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library")
  7. set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory")
  8. ocv_install_3rdparty_licenses(opencl-headers "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/LICENSE.txt")
  9. endif()
  10. mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
  11. if(OPENCL_FOUND)
  12. if(OPENCL_LIBRARY)
  13. set(HAVE_OPENCL_STATIC ON)
  14. set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
  15. else()
  16. set(HAVE_OPENCL_STATIC OFF)
  17. endif()
  18. if(NOT HAVE_OPENCL_STATIC)
  19. try_compile(__VALID_OPENCL
  20. "${OpenCV_BINARY_DIR}"
  21. "${OpenCV_SOURCE_DIR}/cmake/checks/opencl.cpp"
  22. CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
  23. OUTPUT_VARIABLE TRY_OUT
  24. )
  25. if(NOT TRY_OUT MATCHES "OpenCL is valid")
  26. message(WARNING "Can't use OpenCL")
  27. return()
  28. endif()
  29. endif()
  30. set(HAVE_OPENCL 1)
  31. if(WITH_OPENCL_SVM)
  32. set(HAVE_OPENCL_SVM 1)
  33. endif()
  34. set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
  35. if(WITH_OPENCLAMDFFT)
  36. find_path(CLAMDFFT_ROOT_DIR
  37. NAMES include/clAmdFft.h
  38. PATHS ENV CLAMDFFT_PATH ENV ProgramFiles
  39. PATH_SUFFIXES clAmdFft AMD/clAmdFft
  40. DOC "AMD FFT root directory"
  41. NO_DEFAULT_PATH)
  42. find_path(CLAMDFFT_INCLUDE_DIR
  43. NAMES clAmdFft.h
  44. HINTS ${CLAMDFFT_ROOT_DIR}
  45. PATH_SUFFIXES include
  46. DOC "clAmdFft include directory")
  47. if(CLAMDFFT_INCLUDE_DIR)
  48. set(HAVE_CLAMDFFT 1)
  49. list(APPEND OPENCL_INCLUDE_DIRS "${CLAMDFFT_INCLUDE_DIR}")
  50. endif()
  51. endif()
  52. if(WITH_OPENCLAMDBLAS)
  53. find_path(CLAMDBLAS_ROOT_DIR
  54. NAMES include/clAmdBlas.h
  55. PATHS ENV CLAMDBLAS_PATH ENV ProgramFiles
  56. PATH_SUFFIXES clAmdBlas AMD/clAmdBlas
  57. DOC "AMD FFT root directory"
  58. NO_DEFAULT_PATH)
  59. find_path(CLAMDBLAS_INCLUDE_DIR
  60. NAMES clAmdBlas.h
  61. HINTS ${CLAMDBLAS_ROOT_DIR}
  62. PATH_SUFFIXES include
  63. DOC "clAmdFft include directory")
  64. if(CLAMDBLAS_INCLUDE_DIR)
  65. set(HAVE_CLAMDBLAS 1)
  66. list(APPEND OPENCL_INCLUDE_DIRS "${CLAMDBLAS_INCLUDE_DIR}")
  67. endif()
  68. endif()
  69. # check WITH_OPENCL_D3D11_NV is located in OpenCVDetectDirectX.cmake file
  70. if(WITH_VA_INTEL AND HAVE_VA)
  71. if(HAVE_OPENCL AND EXISTS "${OPENCL_INCLUDE_DIR}/CL/cl_va_api_media_sharing_intel.h")
  72. set(HAVE_VA_INTEL ON)
  73. elseif(HAVE_OPENCL AND EXISTS "${OPENCL_INCLUDE_DIR}/CL/va_ext.h")
  74. set(HAVE_VA_INTEL ON)
  75. set(HAVE_VA_INTEL_OLD_HEADER ON)
  76. endif()
  77. endif()
  78. endif()