meson: Add more qt options and eliminate all automagic

The qt5 and qt6 plugins will now correctly error out if you enable the
option, and you can also now explicitly ensure that wayland, x11,
eglfs support is actually functional by enabling the options. It was
too easy to build non-functional support for these.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4537>
This commit is contained in:
Nirbheek Chauhan 2023-05-03 21:05:54 +05:30 committed by GStreamer Marge Bot
parent cb5c0e47c8
commit 93be699ab2
3 changed files with 140 additions and 103 deletions

View file

@ -22,6 +22,9 @@ moc_headers = [
# deciding whether to build the qt5 examples
qt5qml_dep = dependency('', required: false)
qt5_option = get_option('qt5')
qt5_egl = get_option('qt-egl')
qt5_wayland = get_option('qt-wayland')
qt5_x11 = get_option('qt-x11')
qt5_method = get_option('qt-method')
if qt5_option.disabled()
@ -68,18 +71,23 @@ have_qt_windowing = false
# Look for the QPA platform native interface header
qpa_header_path = join_paths(qt5qml_dep.version(), 'QtGui')
qpa_header = join_paths(qpa_header_path, 'qpa/qplatformnativeinterface.h')
if cxx.has_header(qpa_header, dependencies : qt5qml_dep)
need_qpa_include = qt5_option.enabled() and (host_system == 'android' or qt5_wayland.enabled())
if cxx.has_header(qpa_header, dependencies : qt5qml_dep, required: need_qpa_include)
qt_defines += '-DHAVE_QT_QPA_HEADER'
qt_defines += '-DQT_QPA_HEADER=' + '<@0@>'.format(qpa_header)
have_qpa_include = true
message('Found QtGui QPA header in ' + qpa_header_path)
endif
# Try to come up with all the platform/winsys combinations that will work
## Try to come up with all the platform/winsys combinations that will work
if gst_gl_have_window_x11 and gst_gl_have_platform_glx
# FIXME: automagic
qt5x11extras = dependency('qt5', modules : ['X11Extras'], method: qt5_method, required : false)
# X11 windowing
qt5_x11 = qt5_x11 \
.require(gstglx11_dep.found(), error_message: 'gstreamer-gl-x11-1.0 is required') \
.require(gst_gl_have_window_x11, error_message: 'x11 windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_glx, error_message: 'glx platform support in gstreamer-gl is required')
if qt5_x11.allowed()
qt5x11extras = dependency('qt5', modules : ['X11Extras'], method: qt5_method, required: qt5_x11)
if qt5x11extras.found()
optional_deps += [qt5x11extras, gstglx11_dep]
qt_defines += ['-DHAVE_QT_X11']
@ -87,70 +95,96 @@ if gst_gl_have_window_x11 and gst_gl_have_platform_glx
endif
endif
if gst_gl_have_platform_egl
# Embedded linux (e.g. i.MX6) with or without windowing support
# Wayland windowing
qt5_wayland = qt5_wayland \
.require(gstglwayland_dep.found(), error_message: 'gstreamer-gl-wayland-1.0 is required') \
.require(gst_gl_have_window_wayland, error_message: 'wayland windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required') \
.require(have_qpa_include, error_message: 'QPA platform native interface header is required')
if qt5_wayland.allowed()
qt5waylandextras = dependency('qt5', modules : ['WaylandClient'], method: qt5_method, required: qt5_wayland)
if qt5waylandextras.found()
optional_deps += [qt5waylandextras, gstglwayland_dep]
qt_defines += ['-DHAVE_QT_WAYLAND']
have_qt_windowing = true
endif
endif
# EGL windowing for Embedded linux (e.g. i.MX6) with or without windowing
# support
qt5_egl = qt5_egl \
.require(host_system == 'linux') \
.require(gstglegl_dep.found(), error_message: 'gstreamer-gl-egl-1.0 is required') \
.require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required')
if qt5_egl.allowed()
qt_defines += ['-DHAVE_QT_EGLFS']
optional_deps += gstglegl_dep
have_qt_windowing = true
if have_qpa_include
# Wayland windowing
if gst_gl_have_window_wayland
# FIXME: automagic
qt5waylandextras = dependency('qt5', modules : ['WaylandClient'], method: qt5_method, required : false)
if qt5waylandextras.found()
optional_deps += [qt5waylandextras, gstglwayland_dep]
qt_defines += ['-DHAVE_QT_WAYLAND']
have_qt_windowing = true
endif
endif
# Android windowing
if gst_gl_have_window_android
# FIXME: automagic
qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], method: qt5_method, required : false)
# for gl functions in QtGui/qopenglfunctions.h
# FIXME: automagic
glesv2_dep = cc.find_library('GLESv2', required : false)
if glesv2_dep.found() and qt5androidextras.found()
optional_deps += [qt5androidextras, glesv2_dep]
qt_defines += ['-DHAVE_QT_ANDROID']
have_qt_windowing = true
# Needed for C++11 support in Cerbero. People building with Android
# in some other way need to add the necessary bits themselves.
optional_deps += dependency('gnustl', required : false)
endif
endif
# Android windowing
if host_system == 'android'
qt5_android = qt5_option \
.require(gst_gl_have_window_android, error_message: 'android windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required')
if gst_gl_have_window_android
qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], method: qt5_method, required : qt5_android)
# for gl functions in QtGui/qopenglfunctions.h
glesv2_dep = cc.find_library('GLESv2', required : qt5_android)
if glesv2_dep.found() and qt5androidextras.found()
optional_deps += [qt5androidextras, glesv2_dep]
qt_defines += ['-DHAVE_QT_ANDROID']
have_qt_windowing = true
# Needed for C++11 support in Cerbero. People building with Android
# in some other way need to add the necessary bits themselves.
optional_deps += dependency('gnustl', required : false)
endif
endif
endif
if gst_gl_have_platform_wgl and gst_gl_have_window_win32
# for wglMakeCurrent()
# FIXME: automagic
opengl32_dep = cc.find_library('opengl32', required : false)
if opengl32_dep.found()
qt_defines += ['-DHAVE_QT_WIN32']
optional_deps += opengl32_dep
have_qt_windowing = true
# Win32 windowing
if host_system == 'windows'
qt5_win32 = qt5_option \
.require(gst_gl_have_window_win32, error_message: 'win32 windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_wgl, error_message: 'wgl platform support in gstreamer-gl is required')
if qt5_win32.allowed()
# for wglMakeCurrent()
opengl32_dep = cc.find_library('opengl32', required : qt5_win32)
if opengl32_dep.found()
qt_defines += ['-DHAVE_QT_WIN32']
optional_deps += opengl32_dep
have_qt_windowing = true
endif
endif
endif
if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl
# FIXME: automagic
qt5macextras = dependency('qt5', modules : ['MacExtras'], method: qt5_method, required : false)
if qt5macextras.found()
qt_defines += ['-DHAVE_QT_MAC']
optional_deps += qt5macextras
have_qt_windowing = true
# macOS windowing
if host_system == 'darwin'
qt5_macos = qt5_option \
.require(gst_gl_have_window_cocoa, error_message: 'cocoa windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_cgl, error_message: 'cgl platform support in gstreamer-gl is required')
if qt5_macos.allowed()
qt5macextras = dependency('qt5', modules : ['MacExtras'], method: qt5_method, required : qt5_macos)
if qt5macextras.found()
qt_defines += ['-DHAVE_QT_MAC']
optional_deps += qt5macextras
have_qt_windowing = true
endif
endif
endif
if gst_gl_have_window_eagl and gst_gl_have_platform_eagl
if host_machine.system() == 'ios'
# iOS windowing
if host_system == 'ios'
qt5_ios = qt5_option \
.require(gst_gl_have_window_eagl, error_message: 'eagl windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_eagl, error_message: 'eagl platform support in gstreamer-gl is required')
if qt5_ios.allowed()
qt_defines += ['-DHAVE_QT_IOS']
have_qt_windowing = true
endif
endif
if have_qt_windowing
if qt5_option.require(have_qt_windowing).allowed()
# rpath is needed to be able to load the plugin on macOS inside the devenv
qmlgl_kwargs = {}
if host_system == 'darwin'

View file

@ -20,6 +20,9 @@ moc_headers = [
qt6qml_dep = dependency('', required: false)
qt6_option = get_option('qt6')
qt6_egl = get_option('qt-egl')
qt6_wayland = get_option('qt-wayland')
qt6_x11 = get_option('qt-x11')
qt6_method = get_option('qt-method')
if qt6_option.disabled()
@ -59,83 +62,80 @@ have_qt_windowing = false
# Look for the QPA platform native interface header
qpa_header_path = join_paths(qt6qml_dep.version(), 'QtGui')
qpa_header = join_paths(qpa_header_path, 'qpa/qplatformnativeinterface.h')
if cxx.has_header(qpa_header, dependencies : qt6qml_dep)
need_qpa_include = qt6_option.enabled() and (host_system == 'android' or qt6_wayland.enabled())
if cxx.has_header(qpa_header, dependencies : qt6qml_dep, required: need_qpa_include)
qt_defines += '-DHAVE_QT_QPA_HEADER'
qt_defines += '-DQT_QPA_HEADER=' + '<@0@>'.format(qpa_header)
have_qpa_include = true
message('Found QtGui QPA header in ' + qpa_header_path)
endif
# Try to come up with all the platform/winsys combinations that will work
## Try to come up with all the platform/winsys combinations that will work
if gst_gl_have_window_x11 and gst_gl_have_platform_glx
# FIXME: automagic
# X11 windowing
qt6_x11 = qt6_x11 \
.require(gstglx11_dep.found(), error_message: 'gstreamer-gl-x11-1.0 is required') \
.require(gst_gl_have_window_x11, error_message: 'x11 windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_glx, error_message: 'glx platform support in gstreamer-gl is required')
if qt6_x11.allowed()
qt_defines += ['-DHAVE_QT_X11']
have_qt_windowing = true
endif
if gst_gl_have_platform_egl
# Embedded linux (e.g. i.MX6) with or without windowing support
qt_defines += ['-DHAVE_QT_EGLFS']
optional_deps += gstglegl_dep
have_qt_windowing = true
if have_qpa_include
# Wayland windowing
if gst_gl_have_window_wayland
# FIXME: automagic
qt6waylandextras = dependency('qt6', modules : ['WaylandClient'], method: qt6_method, required : false)
if qt6waylandextras.found()
optional_deps += [qt6waylandextras, gstglwayland_dep]
qt_defines += ['-DHAVE_QT_WAYLAND']
have_qt_windowing = true
endif
endif
# Android windowing
# if gst_gl_have_window_android
# FIXME: automagic
# qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], method: qt6_method, required : false)
# for gl functions in QtGui/qopenglfunctions.h
# FIXME: automagic
# glesv2_dep = cc.find_library('GLESv2', required : false)
# if glesv2_dep.found() and qt5androidextras.found()
# optional_deps += [qt5androidextras, glesv2_dep]
# qt_defines += ['-DHAVE_QT_ANDROID']
# have_qt_windowing = true
# Needed for C++11 support in Cerbero. People building with Android
# in some other way need to add the necessary bits themselves.
# optional_deps += dependency('gnustl', required : false)
# endif
# endif
# Wayland windowing
qt6_wayland = qt6_wayland \
.require(gstglwayland_dep.found(), error_message: 'gstreamer-gl-wayland-1.0 is required') \
.require(gst_gl_have_window_wayland, error_message: 'wayland windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required') \
.require(have_qpa_include, error_message: 'QPA platform native interface header is required')
if qt6_wayland.allowed()
qt6waylandextras = dependency('qt6', modules : ['WaylandClient'], method: qt6_method, required: qt6_wayland)
if qt6waylandextras.found()
optional_deps += [qt6waylandextras, gstglwayland_dep]
qt_defines += ['-DHAVE_QT_WAYLAND']
have_qt_windowing = true
endif
endif
#if gst_gl_have_platform_wgl and gst_gl_have_window_win32
# for wglMakeCurrent()
# FIXME: automagic
# opengl32_dep = cc.find_library('opengl32', required : false)
# if opengl32_dep.found()
# qt_defines += ['-DHAVE_QT_WIN32']
# optional_deps += opengl32_dep
# have_qt_windowing = true
# endif
#endif
# EGL windowing for Embedded linux (e.g. i.MX6) with or without windowing
# support
qt6_egl = qt6_egl \
.require(host_system == 'linux') \
.require(gstglegl_dep.found(), error_message: 'gstreamer-gl-egl-1.0 is required') \
.require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required')
if qt6_egl.allowed()
qt_defines += ['-DHAVE_QT_EGLFS']
optional_deps += gstglegl_dep
have_qt_windowing = true
endif
if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl
# FIXME: automagic
if host_machine.system() == 'darwin'
# TODO: Android windowing
# TODO: Win32 windowing
# macOS windowing
if host_system == 'darwin'
qt6_macos = qt6_option \
.require(gst_gl_have_window_cocoa, error_message: 'cocoa windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_cgl, error_message: 'cgl platform support in gstreamer-gl is required')
if qt6_macos.allowed()
qt_defines += ['-DHAVE_QT_MAC']
have_qt_windowing = true
endif
endif
if gst_gl_have_window_eagl and gst_gl_have_platform_eagl
if host_machine.system() == 'ios'
# iOS windowing
if host_system == 'ios'
qt6_ios = qt6_option \
.require(gst_gl_have_window_eagl, error_message: 'eagl windowing support in gstreamer-gl is required') \
.require(gst_gl_have_platform_eagl, error_message: 'eagl platform support in gstreamer-gl is required')
if qt6_ios.allowed()
qt_defines += ['-DHAVE_QT_IOS']
have_qt_windowing = true
endif
endif
if have_qt_windowing
if qt6_option.require(have_qt_windowing).allowed()
# Build it!
moc_files = qt6_mod.preprocess(moc_headers : moc_headers)
gstqml6gl = library('gstqml6', sources, moc_files,

View file

@ -89,6 +89,9 @@ option('rpi-lib-dir', type : 'string', value : '/opt/vc/lib', description : 'Dir
# Qt plugin options
option('qt-method', type: 'combo', value: 'auto', choices: ['auto', 'pkg-config', 'qmake'],
description: 'Method to use to find Qt')
option('qt-egl', type: 'feature', value: 'auto', description: 'EGLFS support in the Qt plugins')
option('qt-wayland', type: 'feature', value: 'auto', description: 'Wayland support in the Qt plugins')
option('qt-x11', type: 'feature', value: 'auto', description: 'Wayland support in the Qt plugins')
option('qt5', type : 'feature', value : 'auto', yield : true, description : 'Qt5 QML video sink plugin')
option('qt6', type : 'feature', value : 'auto', yield : true, description : 'Qt6 QML video sink plugin')