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