Skip to content

Commit

Permalink
CMake: Minor Video Cmake Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Sep 21, 2024
1 parent 2f5db7a commit 9af1296
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 50 deletions.
69 changes: 43 additions & 26 deletions cmake/FindGStreamer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ if(WIN32)
else()
set(GSTREAMER_PREFIX "C:/gstreamer/1.0/msvc_x86_64")
endif()
set(PKG_CONFIG_EXECUTABLE ${GSTREAMER_PREFIX}/bin/pkg-config.exe)
find_program(PKG_CONFIG_PROGRAM pkg-config PATHS ${GSTREAMER_PREFIX}/bin)
if(PKG_CONFIG_PROGRAM)
set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_PROGRAM})
cmake_print_variables(PKG_CONFIG_EXECUTABLE)
endif()
set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/pkgconfig;${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig;$ENV{PKG_CONFIG_PATH}")
# cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/pkgconfig;${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig;$ENV{PKG_CONFIG_PATH}" TO_NATIVE_PATH_LIST PKG_CONFIG_PATH NORMALIZE)
# cmake_print_variables(PKG_CONFIG_PATH)
Expand Down Expand Up @@ -116,6 +120,14 @@ elseif(ANDROID)
--define-variable=includedir=${GSTREAMER_PREFIX}/include
)
cmake_print_variables(PKG_CONFIG_ARGN)

if(CMAKE_HOST_WIN32)
find_program(PKG_CONFIG_PROGRAM pkg-config PATHS ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/tools/windows)
if(PKG_CONFIG_PROGRAM)
set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_PROGRAM})
cmake_print_variables(PKG_CONFIG_EXECUTABLE)
endif()
endif()
endif()
cmake_print_variables(GSTREAMER_PREFIX)
list(PREPEND CMAKE_PREFIX_PATH ${GSTREAMER_PREFIX})
Expand Down Expand Up @@ -237,7 +249,12 @@ endif()

# GStreamer optional components
foreach(component ${GStreamer_FIND_COMPONENTS})
if (${component} STREQUAL "App")
if (${component} STREQUAL "Allocators")
find_gstreamer_component(Allocators gstreamer-allocators-1.0 gst/allocators/allocators.h gstallocators-1.0)
if(TARGET GStreamer::Allocators AND TARGET GStreamer::Core)
target_link_libraries(GStreamer::Allocators INTERFACE GStreamer::Core)
endif()
elseif (${component} STREQUAL "App")
find_gstreamer_component(App gstreamer-app-1.0 gst/app/gstappsink.h gstapp-1.0)
if(TARGET GStreamer::App AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::App INTERFACE GStreamer::Base)
Expand All @@ -247,21 +264,6 @@ foreach(component ${GStreamer_FIND_COMPONENTS})
if(TARGET GStreamer::Audio AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::Audio INTERFACE GStreamer::Base)
endif()
elseif (${component} STREQUAL "Allocators")
find_gstreamer_component(Allocators gstreamer-allocators-1.0 gst/allocators/allocators.h gstallocators-1.0)
if(TARGET GStreamer::Allocators AND TARGET GStreamer::Core)
target_link_libraries(GStreamer::Allocators INTERFACE GStreamer::Core)
endif()
elseif (${component} STREQUAL "Pbutils")
find_gstreamer_component(Pbutils gstreamer-pbutils-1.0 gst/pbutils/pbutils.h gstpbutils-1.0)
if(TARGET GStreamer::Pbutils AND TARGET GStreamer::Audio AND TARGET GStreamer::Video)
target_link_libraries(GStreamer::Pbutils INTERFACE GStreamer::Audio GStreamer::Video)
endif()
elseif (${component} STREQUAL "Photography")
find_gstreamer_component(Photography gstreamer-photography-1.0 gst/interfaces/photography.h gstphotography-1.0)
if(TARGET GStreamer::Photography AND TARGET GStreamer::Core)
target_link_libraries(GStreamer::Photography INTERFACE GStreamer::Core)
endif()
elseif (${component} STREQUAL "Controller")
find_gstreamer_component(Controller gstreamer-controller-1.0 gst/controller/controller.h gstcontroller-1.0)
if(TARGET GStreamer::Controller AND TARGET GStreamer::Core)
Expand All @@ -272,15 +274,30 @@ foreach(component ${GStreamer_FIND_COMPONENTS})
if(TARGET GStreamer::Codecparsers AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::Codecparsers INTERFACE GStreamer::Base)
endif()
elseif (${component} STREQUAL "Fft")
find_gstreamer_component(Fft gstreamer-fft-1.0 gst/fft/fft.h gstfft-1.0)
if(TARGET GStreamer::Fft AND TARGET GStreamer::Core)
target_link_libraries(GStreamer::Fft INTERFACE GStreamer::Core)
endif()
elseif (${component} STREQUAL "Mpegts")
find_gstreamer_component(Mpegts gstreamer-mpegts-1.0 gst/mpegts/mpegts.h gstmpegts-1.0)
if(TARGET GStreamer::Mpegts AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::Mpegts INTERFACE GStreamer::Base)
endif()
elseif (${component} STREQUAL "Net")
find_gstreamer_component(Net gstreamer-net-1.0 gst/net/net.h gstnet-1.0)
if(TARGET GStreamer::Net AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::Net INTERFACE GStreamer::Base)
endif()
elseif (${component} STREQUAL "Fft")
find_gstreamer_component(Fft gstreamer-fft-1.0 gst/fft/fft.h gstfft-1.0)
if(TARGET GStreamer::Fft AND TARGET GStreamer::Core)
target_link_libraries(GStreamer::Fft INTERFACE GStreamer::Core)
elseif (${component} STREQUAL "Pbutils")
find_gstreamer_component(Pbutils gstreamer-pbutils-1.0 gst/pbutils/pbutils.h gstpbutils-1.0)
if(TARGET GStreamer::Pbutils AND TARGET GStreamer::Audio AND TARGET GStreamer::Video)
target_link_libraries(GStreamer::Pbutils INTERFACE GStreamer::Audio GStreamer::Video)
endif()
elseif (${component} STREQUAL "Photography")
find_gstreamer_component(Photography gstreamer-photography-1.0 gst/interfaces/photography.h gstphotography-1.0)
if(TARGET GStreamer::Photography AND TARGET GStreamer::Core)
target_link_libraries(GStreamer::Photography INTERFACE GStreamer::Core)
endif()
elseif (${component} STREQUAL "Riff")
find_gstreamer_component(Riff gstreamer-riff-1.0 gst/riff/riff.h gstriff-1.0)
Expand All @@ -297,11 +314,6 @@ foreach(component ${GStreamer_FIND_COMPONENTS})
if(TARGET GStreamer::Rtsp AND TARGET GStreamer::Rtp)
target_link_libraries(GStreamer::Rtsp INTERFACE GStreamer::Rtp)
endif()
elseif (${component} STREQUAL "Mpegts")
find_gstreamer_component(Mpegts gstreamer-mpegts-1.0 gst/mpegts/mpegts.h gstmpegts-1.0)
if(TARGET GStreamer::Mpegts AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::Mpegts INTERFACE GStreamer::Base)
endif()
elseif (${component} STREQUAL "Sdp")
find_gstreamer_component(Sdp gstreamer-sdp-1.0 gst/sdp/sdp.h gstsdp-1.0)
if(TARGET GStreamer::Sdp AND TARGET GStreamer::Rtp)
Expand All @@ -312,6 +324,11 @@ foreach(component ${GStreamer_FIND_COMPONENTS})
if(TARGET GStreamer::Tag AND TARGET GStreamer::Base)
target_link_libraries(GStreamer::Tag INTERFACE GStreamer::Base)
endif()
elseif (${component} STREQUAL "Va")
find_gstreamer_component(Va gstreamer-va-1.0 gst/va/gstva.h gstva-1.0)
if(TARGET GStreamer::Va AND TARGET GStreamer::Base AND TARGET GStreamer::Allocators)
target_link_libraries(GStreamer::Va INTERFACE GStreamer::Base GStreamer::Allocators)
endif()
elseif (${component} STREQUAL "Prototypes")
find_gstreamer_component(Prototypes gstreamer-gl-prototypes-1.0 gst/gl/glprototypes/all_functions.h gstglproto-1.0)
if(TARGET GStreamer::Prototypes AND TARGET GStreamer::Gl)
Expand Down
1 change: 0 additions & 1 deletion src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ if(IOS)
)
endif()


target_link_libraries(GStreamerReceiver
PRIVATE
Utilities
Expand Down
51 changes: 28 additions & 23 deletions src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(GStreamer REQUIRED COMPONENTS Codecparsers Controller Mpegts Net Pbutils Riff Rtp Rtsp OPTIONAL_COMPONENTS Photography X11 EGL Wayland)
find_package(GStreamer REQUIRED COMPONENTS Allocators Audio Codecparsers Controller Mpegts Net Pbutils Riff Rtp Rtsp Sdp Tag OPTIONAL_COMPONENTS Va Photography X11 EGL Wayland)

# Use Latest Revisions for each minor version: 1.16.3, 1.18.6, 1.20.7, 1.22.12, 1.24.7
string(REPLACE "." ";" GST_VERSION_LIST ${GStreamer_VERSION})
Expand Down Expand Up @@ -52,6 +52,8 @@ file(GLOB gstqml6gl_SRCS
)
qt_add_library(gstqml6gl STATIC ${gstqml6gl_SRCS})

target_include_directories(gstqml6gl PUBLIC ${QGC_GST_QT6_PLUGIN_PATH})

find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)

target_link_libraries(gstqml6gl
Expand All @@ -63,6 +65,8 @@ target_link_libraries(gstqml6gl
Qt6::Qml
Qt6::Quick
GStreamer::GStreamer
GStreamer::Allocators
GStreamer::Audio
GStreamer::Codecparsers
GStreamer::Controller
GStreamer::Mpegts
Expand All @@ -71,14 +75,18 @@ target_link_libraries(gstqml6gl
GStreamer::Riff
GStreamer::Rtp
GStreamer::Rtsp
GStreamer::Sdp
GStreamer::Tag
)

# Photography not found on ubuntu 20.04?
if(GStreamer_Photography_FOUND)
target_link_libraries(gstqml6gl PUBLIC GStreamer::Photography)
endif()

target_include_directories(gstqml6gl PUBLIC ${QGC_GST_QT6_PLUGIN_PATH})
if(GStreamer_Va_FOUND)
target_link_libraries(gstqml6gl PUBLIC GStreamer::Va)
endif()

if(GStreamer_X11_FOUND)
# X11, XCB, X11_XCB, GLX
Expand Down Expand Up @@ -172,6 +180,7 @@ if(UNIX)
)
endif()

# gstva, gstasf
set(GST_TARGET_PLUGINS
gstcoreelements
gstisomp4
Expand Down Expand Up @@ -206,6 +215,11 @@ if(PkgConfig_FOUND)
install(FILES ${GST_PLUGINS_LIBRARIES} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()

pkg_check_modules(GSTREAMER_PLUGINS_BASE IMPORTED_TARGET gstreamer-plugins-base-1.0)
if(GSTREAMER_PLUGINS_BASE_FOUND)
target_link_libraries(gstqml6gl PUBLIC PkgConfig::GSTREAMER_PLUGINS_BASE)
endif()
endif()

if(NOT GST_PLUGINS_FOUND)
Expand All @@ -220,8 +234,8 @@ if(NOT GST_PLUGINS_FOUND)
${GSTREAMER_PREFIX}/Versions/Current/lib
${GSTREAMER_PREFIX}/Versions/Current/lib/gstreamer-1.0
)
cmake_print_variables(GStreamer_${plugin}_LIBRARY)
if(GStreamer_${plugin}_LIBRARY)
cmake_print_variables(GStreamer_${plugin}_LIBRARY)
target_link_libraries(gstqml6gl PUBLIC ${GStreamer_${plugin}_LIBRARY})
if(WIN32)
# install(FILES ${GStreamer_${plugin}_LIBRARY} DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -237,6 +251,7 @@ if(NOT GST_PLUGINS_FOUND)
${GSTREAMER_PREFIX}/include/gstreamer-1.0
${GSTREAMER_PREFIX}/include/glib-2.0
${GSTREAMER_PREFIX}/lib/glib-2.0/include
${GSTREAMER_PREFIX}/lib/graphene-1.0/include
${GSTREAMER_PREFIX}/lib/gstreamer-1.0/include
${GSTREAMER_PREFIX}/include
)
Expand Down Expand Up @@ -287,9 +302,16 @@ if(LINUX)
install(DIRECTORY ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gstreamer1.0 DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gio DESTINATION ${CMAKE_INSTALL_LIBDIR})
elseif(WIN32)
# install(FILES ${GSTREAMER_PREFIX}/libexec/gstreamer-1.0/gst-plugin-scanner DESTINATION ${CMAKE_INSTALL_BINDIR})
# install(FILES ${GSTREAMER_PREFIX}/libexec/gstreamer-1.0/gst-ptp-helper DESTINATION ${CMAKE_INSTALL_BINDIR})
# install(DIRECTORY ${GSTREAMER_PREFIX}/lib/gio DESTINATION ${CMAKE_INSTALL_BINDIR})
cmake_path(CONVERT "${GSTREAMER_PREFIX}/libexec/gstreamer-1.0/*.exe" TO_CMAKE_PATH_LIST GST_HELPER_BINS_PATH)
file(GLOB GST_HELPER_BINS ${GST_HELPER_BINS_PATH})
install(FILES ${GST_HELPER_BINS} DESTINATION ${CMAKE_INSTALL_BINDIR})

cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/gio" TO_CMAKE_PATH_LIST GST_GIO_PATH)
install(DIRECTORY ${GST_GIO_PATH} DESTINATION ${CMAKE_INSTALL_BINDIR})

# cmake_path(CONVERT "${GSTREAMER_PREFIX}/share/gstreamer/gst-env" TO_CMAKE_PATH_LIST GST_SHARE_ENV_PATH)
# TODO: update GSTREAMER_ROOT & install
# install(CODE GST_SHARE_ENV_PATH)
endif()

if(WIN32)
Expand All @@ -305,20 +327,3 @@ if(WIN32)
file(GLOB GST_WIN_PLUGINS ${GST_WIN_PLUGINS_PATH})
install(FILES ${GST_WIN_PLUGINS} DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

# if(ANDROID)
# configure_file(
# ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/gstreamer_android-1.0.c.in
# ${CMAKE_BINARY_DIR}/gstreamer_android-1.0.c
# @ONLY
# )
# target_sources(gstqml6gl PRIVATE ${CMAKE_BINARY_DIR}/gstreamer_android-1.0.c)
# install(
# DIRECTORY ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/androidmedia
# DESTINATION ${CMAKE_SOURCE_DIR}/android/src/org/freedesktop/gstreamer/androidmedia
# )
# install(
# FILES ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/GStreamer.java
# DESTINATION ${CMAKE_SOURCE_DIR}/android/src/org/freedesktop/gstreamer/androidmedia/GStreamer.java
# )
# endif()

0 comments on commit 9af1296

Please sign in to comment.