detect_gstreamer.cmake 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # --- GStreamer ---
  2. if(NOT HAVE_GSTREAMER AND WIN32)
  3. set(env_paths "${GSTREAMER_DIR}" ENV GSTREAMER_ROOT)
  4. if(X86_64)
  5. list(APPEND env_paths ENV GSTREAMER_1_0_ROOT_X86_64 ENV GSTREAMER_ROOT_X86_64)
  6. else()
  7. list(APPEND env_paths ENV GSTREAMER_1_0_ROOT_X86 ENV GSTREAMER_ROOT_X86)
  8. endif()
  9. find_path(GSTREAMER_gst_INCLUDE_DIR
  10. gst/gst.h
  11. PATHS ${env_paths}
  12. PATH_SUFFIXES "include/gstreamer-1.0")
  13. find_path(GSTREAMER_glib_INCLUDE_DIR
  14. glib.h
  15. PATHS ${env_paths}
  16. PATH_SUFFIXES "include/glib-2.0")
  17. find_path(GSTREAMER_glibconfig_INCLUDE_DIR
  18. glibconfig.h
  19. PATHS ${env_paths}
  20. PATH_SUFFIXES "lib/glib-2.0/include")
  21. find_library(GSTREAMER_gstreamer_LIBRARY
  22. NAMES gstreamer gstreamer-1.0
  23. PATHS ${env_paths}
  24. PATH_SUFFIXES "lib")
  25. find_library(GSTREAMER_app_LIBRARY
  26. NAMES gstapp gstapp-1.0
  27. PATHS ${env_paths}
  28. PATH_SUFFIXES "lib")
  29. find_library(GSTREAMER_base_LIBRARY
  30. NAMES gstbase gstbase-1.0
  31. PATHS ${env_paths}
  32. PATH_SUFFIXES "lib")
  33. find_library(GSTREAMER_pbutils_LIBRARY
  34. NAMES gstpbutils gstpbutils-1.0
  35. PATHS ${env_paths}
  36. PATH_SUFFIXES "lib")
  37. find_library(GSTREAMER_riff_LIBRARY
  38. NAMES gstriff gstriff-1.0
  39. PATHS ${env_paths}
  40. PATH_SUFFIXES "lib")
  41. find_library(GSTREAMER_video_LIBRARY
  42. NAMES gstvideo gstvideo-1.0
  43. PATHS ${env_paths}
  44. PATH_SUFFIXES "lib")
  45. find_library(GSTREAMER_audio_LIBRARY
  46. NAMES gstaudio gstaudio-1.0
  47. PATHS ${env_paths}
  48. PATH_SUFFIXES "lib")
  49. find_library(GSTREAMER_glib_LIBRARY
  50. NAMES glib-2.0
  51. PATHS ${env_paths}
  52. PATH_SUFFIXES "lib")
  53. find_library(GSTREAMER_gobject_LIBRARY
  54. NAMES gobject-2.0
  55. PATHS ${env_paths}
  56. PATH_SUFFIXES "lib")
  57. if(GSTREAMER_gst_INCLUDE_DIR
  58. AND GSTREAMER_glib_INCLUDE_DIR
  59. AND GSTREAMER_glibconfig_INCLUDE_DIR
  60. AND GSTREAMER_gstreamer_LIBRARY
  61. AND GSTREAMER_app_LIBRARY
  62. AND GSTREAMER_base_LIBRARY
  63. AND GSTREAMER_pbutils_LIBRARY
  64. AND GSTREAMER_riff_LIBRARY
  65. AND GSTREAMER_video_LIBRARY
  66. AND GSTREAMER_audio_LIBRARY
  67. AND GSTREAMER_glib_LIBRARY
  68. AND GSTREAMER_gobject_LIBRARY)
  69. file(STRINGS "${GSTREAMER_gst_INCLUDE_DIR}/gst/gstversion.h" ver_strings REGEX "#define +GST_VERSION_(MAJOR|MINOR|MICRO|NANO).*")
  70. string(REGEX REPLACE ".*GST_VERSION_MAJOR[^0-9]+([0-9]+).*" "\\1" ver_major "${ver_strings}")
  71. string(REGEX REPLACE ".*GST_VERSION_MINOR[^0-9]+([0-9]+).*" "\\1" ver_minor "${ver_strings}")
  72. string(REGEX REPLACE ".*GST_VERSION_MICRO[^0-9]+([0-9]+).*" "\\1" ver_micro "${ver_strings}")
  73. set(GSTREAMER_VERSION "${ver_major}.${ver_minor}.${ver_micro}") # informational
  74. set(HAVE_GSTREAMER TRUE)
  75. set(GSTREAMER_LIBRARIES
  76. ${GSTREAMER_gstreamer_LIBRARY}
  77. ${GSTREAMER_base_LIBRARY}
  78. ${GSTREAMER_app_LIBRARY}
  79. ${GSTREAMER_riff_LIBRARY}
  80. ${GSTREAMER_video_LIBRARY}
  81. ${GSTREAMER_audio_LIBRARY}
  82. ${GSTREAMER_pbutils_LIBRARY}
  83. ${GSTREAMER_glib_LIBRARY}
  84. ${GSTREAMER_gobject_LIBRARY})
  85. set(GSTREAMER_INCLUDE_DIRS
  86. ${GSTREAMER_gst_INCLUDE_DIR}
  87. ${GSTREAMER_glib_INCLUDE_DIR}
  88. ${GSTREAMER_glibconfig_INCLUDE_DIR})
  89. endif()
  90. endif()
  91. if(NOT HAVE_GSTREAMER AND PKG_CONFIG_FOUND)
  92. ocv_check_modules(GSTREAMER_base gstreamer-base-1.0)
  93. ocv_check_modules(GSTREAMER_app gstreamer-app-1.0)
  94. ocv_check_modules(GSTREAMER_riff gstreamer-riff-1.0)
  95. ocv_check_modules(GSTREAMER_pbutils gstreamer-pbutils-1.0)
  96. ocv_check_modules(GSTREAMER_video gstreamer-video-1.0)
  97. ocv_check_modules(GSTREAMER_audio gstreamer-audio-1.0)
  98. if(GSTREAMER_base_FOUND AND GSTREAMER_app_FOUND AND GSTREAMER_riff_FOUND AND GSTREAMER_pbutils_FOUND AND GSTREAMER_video_FOUND AND GSTREAMER_audio_FOUND)
  99. set(HAVE_GSTREAMER TRUE)
  100. set(GSTREAMER_VERSION ${GSTREAMER_base_VERSION}) # informational
  101. set(GSTREAMER_LIBRARIES ${GSTREAMER_base_LIBRARIES} ${GSTREAMER_app_LIBRARIES} ${GSTREAMER_riff_LIBRARIES} ${GSTREAMER_pbutils_LIBRARIES} ${GSTREAMER_video_LIBRARIES} ${GSTREAMER_audio_LIBRARIES})
  102. set(GSTREAMER_INCLUDE_DIRS ${GSTREAMER_base_INCLUDE_DIRS} ${GSTREAMER_app_INCLUDE_DIRS} ${GSTREAMER_riff_INCLUDE_DIRS} ${GSTREAMER_pbutils_INCLUDE_DIRS} ${GSTREAMER_video_INCLUDE_DIRS} ${GSTREAMER_audio_INCLUDE_DIRS})
  103. endif()
  104. endif()
  105. if(HAVE_GSTREAMER)
  106. ocv_add_external_target(gstreamer "${GSTREAMER_INCLUDE_DIRS}" "${GSTREAMER_LIBRARIES}" "HAVE_GSTREAMER")
  107. endif()