Merge pull request #11882 from alalek:videoio_vfw_lower_priority
[platform/upstream/opencv.git] / cmake / FindOpenVX.cmake
1 ocv_clear_vars(HAVE_OPENVX)
2
3 set(OPENVX_ROOT "" CACHE PATH "OpenVX install directory")
4 set(OPENVX_LIB_CANDIDATES "openvx;vxu" CACHE STRING "OpenVX library candidates list")
5
6 function(find_openvx_libs _found)
7   foreach(one ${OPENVX_LIB_CANDIDATES})
8     find_library(OPENVX_${one}_LIBRARY ${one} PATHS "${OPENVX_ROOT}/lib" "${OPENVX_ROOT}/bin")
9     if(OPENVX_${one}_LIBRARY)
10       list(APPEND _list ${OPENVX_${one}_LIBRARY})
11     endif()
12   endforeach()
13   set(${_found} ${_list} PARENT_SCOPE)
14 endfunction()
15
16 if(OPENVX_ROOT)
17   find_path(OPENVX_INCLUDE_DIR "VX/vx.h" PATHS "${OPENVX_ROOT}/include" DOC "OpenVX include path")
18   if(NOT DEFINED OPENVX_LIBRARIES)
19     find_openvx_libs(found)
20     if(found)
21       set(OPENVX_LIBRARIES "${found}" CACHE STRING "OpenVX libraries")
22     endif()
23   endif()
24 endif()
25
26 if(OPENVX_INCLUDE_DIR AND OPENVX_LIBRARIES)
27   set(HAVE_OPENVX TRUE)
28
29   try_compile(OPENVX_RENAMED_REF
30       "${OpenCV_BINARY_DIR}"
31       "${OpenCV_SOURCE_DIR}/cmake/checks/openvx_refenum_test.cpp"
32       CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENVX_INCLUDE_DIR}"
33       LINK_LIBRARIES ${OPENVX_LIBRARIES}
34       OUTPUT_VARIABLE OUTPUT
35   )
36   if(OPENVX_RENAMED_REF)
37       add_definitions(-DIVX_RENAMED_REFS=1)
38       message(STATUS "OpenVX: Checking reference attribute name convention... New")
39   else()
40       message(STATUS "OpenVX: Checking reference attribute name convention... Old")
41   endif()
42 endif()
43
44 if(NOT HAVE_OPENVX)
45   ocv_clear_vars(HAVE_OPENVX OPENVX_LIBRARIES OPENVX_INCLUDE_DIR)
46 endif()