detect_msdk.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. set(MFX_DEFS "")
  2. if(NOT HAVE_MFX)
  3. find_package(VPL QUIET)
  4. if(VPL_FOUND)
  5. message(STATUS "VPL_VERSION: ${VPL_VERSION}")
  6. # NOTE: oneVPL since 2021.4 have version 2.4, version 2021.1 does not work
  7. if (VPL_VERSION VERSION_LESS "2021.2" AND VPL_VERSION VERSION_GREATER "2021.0")
  8. message(STATUS "VPL version is too old (${VPL_DIR} : ${VPL_VERSION}) - skipping")
  9. else()
  10. set(MFX_INCLUDE_DIRS "")
  11. set(MFX_LIBRARIES "${VPL_IMPORTED_TARGETS}")
  12. set(HAVE_MFX TRUE)
  13. list(APPEND MFX_DEFS "HAVE_ONEVPL")
  14. endif()
  15. endif()
  16. endif()
  17. set(paths)
  18. if(NOT HAVE_MFX)
  19. set(paths "${MFX_HOME}" ENV "MFX_HOME" ENV "INTELMEDIASDKROOT" ${paths})
  20. if(MSVC)
  21. if(MSVC_VERSION LESS 1900)
  22. set(vs_suffix)
  23. else()
  24. set(vs_suffix "_vs2015")
  25. endif()
  26. if(X86_64)
  27. set(vs_arch "x64")
  28. else()
  29. set(vs_arch "win32")
  30. endif()
  31. endif()
  32. find_path(MFX_INCLUDE mfxdefs.h
  33. PATHS ${paths}
  34. PATH_SUFFIXES "include" "include/mfx"
  35. NO_DEFAULT_PATH)
  36. find_library(MFX_LIBRARY NAMES mfx libmfx${vs_suffix}
  37. PATHS ${paths}
  38. PATH_SUFFIXES "lib64" "lib/lin_x64" "lib/${vs_arch}" "lib"
  39. NO_DEFAULT_PATH)
  40. if(MFX_INCLUDE AND MFX_LIBRARY)
  41. set(HAVE_MFX TRUE)
  42. set(MFX_INCLUDE_DIRS "${MFX_INCLUDE}")
  43. set(MFX_LIBRARIES "${MFX_LIBRARY}")
  44. list(APPEND MFX_DEFS "HAVE_MFX_PLUGIN")
  45. endif()
  46. endif()
  47. if(NOT HAVE_MFX AND PKG_CONFIG_FOUND)
  48. ocv_check_modules(MFX mfx)
  49. endif()
  50. if(HAVE_MFX AND UNIX)
  51. set(paths "${VA_ROOT_DIR}" ENV "VA_ROOT_DIR" ${paths})
  52. foreach(mode NO_DEFAULT_PATH "")
  53. find_path(MFX_va_INCLUDE va/va.h PATHS ${paths} PATH_SUFFIXES "include" ${mode})
  54. find_library(MFX_va_LIBRARY va PATHS ${paths} PATH_SUFFIXES "lib64" "lib/lin_x64" "lib" ${mode})
  55. find_library(MFX_va_drm_LIBRARY va-drm PATHS ${paths} PATH_SUFFIXES "lib64" "lib/lin_x64" "lib" ${mode})
  56. if(MFX_va_INCLUDE AND MFX_va_LIBRARY AND MFX_va_drm_LIBRARY)
  57. list(APPEND MFX_INCLUDE_DIRS "${MFX_va_INCLUDE}")
  58. list(APPEND MFX_LIBRARIES "${MFX_va_LIBRARY}" "${MFX_va_drm_LIBRARY}")
  59. # list(APPEND MFX_LIBRARIES "-Wl,--exclude-libs=libmfx")
  60. break()
  61. endif()
  62. unset(MFX_va_INCLUDE CACHE)
  63. unset(MFX_va_LIBRARY CACHE)
  64. unset(MFX_va_drm_LIBRARY CACHE)
  65. endforeach()
  66. if(NOT(MFX_va_INCLUDE AND MFX_va_LIBRARY AND MFX_va_drm_LIBRARY))
  67. message(STATUS "libva not found - turning MFX OFF")
  68. set(HAVE_MFX FALSE)
  69. endif()
  70. endif()
  71. if(HAVE_MFX)
  72. list(APPEND MFX_DEFS "HAVE_MFX")
  73. ocv_add_external_target(mediasdk "${MFX_INCLUDE_DIRS}" "${MFX_LIBRARIES}" "${MFX_DEFS}")
  74. endif()