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

View file

@ -20,6 +20,9 @@ moc_headers = [
qt6qml_dep = dependency('', required: false) qt6qml_dep = dependency('', required: false)
qt6_option = get_option('qt6') 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') qt6_method = get_option('qt-method')
if qt6_option.disabled() if qt6_option.disabled()
@ -59,83 +62,80 @@ have_qt_windowing = false
# Look for the QPA platform native interface header # Look for the QPA platform native interface header
qpa_header_path = join_paths(qt6qml_dep.version(), 'QtGui') qpa_header_path = join_paths(qt6qml_dep.version(), 'QtGui')
qpa_header = join_paths(qpa_header_path, 'qpa/qplatformnativeinterface.h') 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 += '-DHAVE_QT_QPA_HEADER'
qt_defines += '-DQT_QPA_HEADER=' + '<@0@>'.format(qpa_header) qt_defines += '-DQT_QPA_HEADER=' + '<@0@>'.format(qpa_header)
have_qpa_include = true have_qpa_include = true
message('Found QtGui QPA header in ' + qpa_header_path) message('Found QtGui QPA header in ' + qpa_header_path)
endif 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 # X11 windowing
# FIXME: automagic 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'] qt_defines += ['-DHAVE_QT_X11']
have_qt_windowing = true have_qt_windowing = true
endif endif
if gst_gl_have_platform_egl # Wayland windowing
# Embedded linux (e.g. i.MX6) with or without windowing support qt6_wayland = qt6_wayland \
qt_defines += ['-DHAVE_QT_EGLFS'] .require(gstglwayland_dep.found(), error_message: 'gstreamer-gl-wayland-1.0 is required') \
optional_deps += gstglegl_dep .require(gst_gl_have_window_wayland, error_message: 'wayland windowing support in gstreamer-gl is required') \
have_qt_windowing = true .require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required') \
if have_qpa_include .require(have_qpa_include, error_message: 'QPA platform native interface header is required')
# Wayland windowing if qt6_wayland.allowed()
if gst_gl_have_window_wayland qt6waylandextras = dependency('qt6', modules : ['WaylandClient'], method: qt6_method, required: qt6_wayland)
# FIXME: automagic if qt6waylandextras.found()
qt6waylandextras = dependency('qt6', modules : ['WaylandClient'], method: qt6_method, required : false) optional_deps += [qt6waylandextras, gstglwayland_dep]
if qt6waylandextras.found() qt_defines += ['-DHAVE_QT_WAYLAND']
optional_deps += [qt6waylandextras, gstglwayland_dep] have_qt_windowing = true
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
endif endif
endif endif
#if gst_gl_have_platform_wgl and gst_gl_have_window_win32 # EGL windowing for Embedded linux (e.g. i.MX6) with or without windowing
# for wglMakeCurrent() # support
# FIXME: automagic qt6_egl = qt6_egl \
# opengl32_dep = cc.find_library('opengl32', required : false) .require(host_system == 'linux') \
# if opengl32_dep.found() .require(gstglegl_dep.found(), error_message: 'gstreamer-gl-egl-1.0 is required') \
# qt_defines += ['-DHAVE_QT_WIN32'] .require(gst_gl_have_platform_egl, error_message: 'egl platform support in gstreamer-gl is required')
# optional_deps += opengl32_dep if qt6_egl.allowed()
# have_qt_windowing = true qt_defines += ['-DHAVE_QT_EGLFS']
# endif optional_deps += gstglegl_dep
#endif have_qt_windowing = true
endif
if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl # TODO: Android windowing
# FIXME: automagic
if host_machine.system() == 'darwin' # 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'] qt_defines += ['-DHAVE_QT_MAC']
have_qt_windowing = true have_qt_windowing = true
endif endif
endif endif
if gst_gl_have_window_eagl and gst_gl_have_platform_eagl # iOS windowing
if host_machine.system() == 'ios' 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'] qt_defines += ['-DHAVE_QT_IOS']
have_qt_windowing = true have_qt_windowing = true
endif endif
endif endif
if have_qt_windowing if qt6_option.require(have_qt_windowing).allowed()
# Build it! # Build it!
moc_files = qt6_mod.preprocess(moc_headers : moc_headers) moc_files = qt6_mod.preprocess(moc_headers : moc_headers)
gstqml6gl = library('gstqml6', sources, moc_files, 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 # Qt plugin options
option('qt-method', type: 'combo', value: 'auto', choices: ['auto', 'pkg-config', 'qmake'], option('qt-method', type: 'combo', value: 'auto', choices: ['auto', 'pkg-config', 'qmake'],
description: 'Method to use to find Qt') 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('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') option('qt6', type : 'feature', value : 'auto', yield : true, description : 'Qt6 QML video sink plugin')