OpenCVFindTIMVX.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. set(TIMVX_INSTALL_DIR "" CACHE PATH "Path to libtim-vx installation")
  2. set(VIVANTE_SDK_DIR "" CACHE PATH "Path to VIVANTE SDK needed by TIM-VX.")
  3. set(VIVANTE_SDK_LIB_CANDIDATES "OpenVX;VSC;GAL;ArchModelSw;NNArchPerf" CACHE STRING "VIVANTE SDK library candidates")
  4. # Ensure VIVANTE SDK library candidates are present in given search path
  5. function(find_vivante_sdk_libs _viv_notfound _viv_search_path)
  6. foreach(one ${VIVANTE_SDK_LIB_CANDIDATES})
  7. #NO_DEFAULT_PATH is used to ensure VIVANTE SDK libs are from one only source
  8. find_library(VIV_${one}_LIB ${one} PATHS "${_viv_search_path}/lib" NO_DEFAULT_PATH)
  9. if(NOT VIV_${one}_LIB)
  10. list(APPEND _viv_notfound_list ${one})
  11. endif()
  12. endforeach()
  13. set(${_viv_notfound} ${_viv_notfound_list} PARENT_SCOPE)
  14. endfunction()
  15. # Default value for VIVANTE_SDK_DIR: /usr
  16. if(NOT VIVANTE_SDK_DIR)
  17. set(VIVANTE_SDK_DIR "/usr")
  18. endif()
  19. # Environment variable VIVANTE_SDK_DIR overrides the one in this script
  20. if(DEFINED ENV{VIVANTE_SDK_DIR})
  21. set(VIVANTE_SDK_DIR $ENV{VIVANTE_SDK_DIR})
  22. message(STATUS "TIM-VX: Load VIVANTE_SDK_DIR from system environment: ${VIVANTE_SDK_DIR}")
  23. endif()
  24. # Compile with pre-installed TIM-VX; Or compile together with TIM-VX from source
  25. if(TIMVX_INSTALL_DIR AND NOT BUILD_TIMVX)
  26. message(STATUS "TIM-VX: Use binaries at ${TIMVX_INSTALL_DIR}")
  27. set(BUILD_TIMVX OFF)
  28. set(TIMVX_INC_DIR "${TIMVX_INSTALL_DIR}/include" CACHE INTERNAL "TIM-VX include directory")
  29. find_library(TIMVX_LIB "tim-vx" PATHS "${TIMVX_INSTALL_DIR}/lib" NO_DEFAULT_PATH)
  30. if(TIMVX_LIB)
  31. set(TIMVX_FOUND ON)
  32. else()
  33. set(TIMVX_FOUND OFF)
  34. endif()
  35. # Verify if requested VIVANTE SDK libraries are all found
  36. find_vivante_sdk_libs(missing ${VIVANTE_SDK_DIR})
  37. if(missing)
  38. message(STATUS "TIM-VX: Failed to find ${missing} in ${VIVANTE_SDK_DIR}/lib. Turning off TIMVX_VIV_FOUND")
  39. set(TIMVX_VIV_FOUND OFF)
  40. else()
  41. message(STATUS "TIM-VX: dependent VIVANTE SDK libraries are found at ${VIVANTE_SDK_DIR}/lib.")
  42. set(TIMVX_VIV_FOUND ON)
  43. endif()
  44. else()
  45. message(STATUS "TIM-VX: Build from source")
  46. include("${OpenCV_SOURCE_DIR}/3rdparty/libtim-vx/tim-vx.cmake")
  47. endif()
  48. if(TIMVX_FOUND AND TIMVX_VIV_FOUND)
  49. set(HAVE_TIMVX 1)
  50. message(STATUS "TIM-VX: Found TIM-VX includes: ${TIMVX_INC_DIR}")
  51. message(STATUS "TIM-VX: Found TIM-VX library: ${TIMVX_LIB}")
  52. set(TIMVX_LIBRARY ${TIMVX_LIB})
  53. set(TIMVX_INCLUDE_DIR ${TIMVX_INC_DIR})
  54. message(STATUS "TIM-VX: Found VIVANTE SDK libraries: ${VIVANTE_SDK_DIR}/lib")
  55. link_directories(${VIVANTE_SDK_DIR}/lib)
  56. endif()
  57. MARK_AS_ADVANCED(
  58. TIMVX_INC_DIR
  59. TIMVX_LIB
  60. )