- bump meson minimum version to 0.57 for module qt6 feature - add optional Qt6 detection - add optional C++ standard gnu++17 as needed for Qt6 - adjust qt_opengl_test inline source code and compile arguments ('-std=gnu++17') for optional Qt6 Signed-off-by: Peter Seiderer <ps.report@xxxxxxx> --- meson.build | 52 ++++++++++++++++++++++++++++----------- utils/qv4l2/meson.build | 24 ++++++++++++------ utils/qvidcap/meson.build | 22 +++++++++++------ 3 files changed, 69 insertions(+), 29 deletions(-) diff --git a/meson.build b/meson.build index 233cbab0..b4018c82 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('v4l-utils', 'c', 'cpp', version: '1.27.0', - meson_version : '>= 0.54', + meson_version : '>= 0.57', default_options : [ 'buildtype=debugoptimized', 'warning_level=1', @@ -23,6 +23,7 @@ sys_root = meson.get_external_property('sys_root', '/') fs = import('fs') i18n = import('i18n') pkg = import('pkgconfig') +qt6 = import('qt6') qt5 = import('qt5') as_version = meson.project_version() @@ -89,11 +90,27 @@ dep_libdl = cc.find_library('dl') dep_libelf = cc.find_library('elf', required : get_option('bpf')) dep_libm = cc.find_library('m') dep_librt = cc.find_library('rt') -dep_qt5 = dependency('qt5', modules: ['Core', 'Gui', 'Widgets'], - required : get_option('qvidcap').enabled() or get_option('qv4l2').enabled()) - -dep_qt5_opengl = dependency('qt5', modules: ['OpenGL'], - required : get_option('qvidcap').enabled()) +dep_qt6 = dependency('qt6', modules: ['Core', 'Gui', 'Widgets', 'Core5Compat'], required: false) +if dep_qt6.found() + dep_qt_opengl = dependency('qt6', modules: ['OpenGL', 'OpenGLWidgets'], + required : get_option('qvidcap').enabled()) + dep_qt = dep_qt6 + dep_qt_version = 'Qt6' + dep_qt_options = ['cpp_std=gnu++17'] + dep_qt_args = ['-std=gnu++17'] +else + dep_qt = dependency('qt5', modules: ['Core', 'Gui', 'Widgets'], + required : get_option('qvidcap').enabled() or get_option('qv4l2').enabled()) + if dep_qt.found() + dep_qt_version = 'Qt5' + else + dep_qt_version = '' + endif + dep_qt_opengl = dependency('qt5', modules: ['OpenGL'], + required : get_option('qvidcap').enabled()) + dep_qt_options = [] + dep_qt_args = [] +endif dep_libbpf = dependency('libbpf', required : get_option('bpf'), version : '>=0.7') @@ -289,23 +306,30 @@ if udevdir == '' udevdir = '/lib/udev' endif -qt5_opengl_test = ''' +qt_opengl_test = ''' #define GL_GLEXT_PROTOTYPES #define QT_NO_OPENGL_ES_2 +#include <QtCore> +#if QT_VERSION < 0x060000 #include <QGLWidget> #include <QGLShader> #include <QGLShaderProgram> #include <QGLFunctions> +#else +#include <QOpenGLWidget> +#include <QOpenGLFunctions> +#include <QOpenGLShaderProgram> +#endif #ifndef GL_UNSIGNED_INT_8_8_8_8 #error Missing OpenGL Extensions #endif ''' -have_qt5_opengl = cpp.compiles(qt5_opengl_test, - dependencies : [dep_gl, dep_qt5, dep_qt5_opengl], - args : '-fPIC') -if have_qt5_opengl +have_qt_opengl = cpp.compiles(qt_opengl_test, + dependencies : [dep_gl, dep_qt, dep_qt_opengl], + args : ['-fPIC'] + dep_qt_args) +if have_qt_opengl conf.set('HAVE_QTGL', 1) endif @@ -379,9 +403,9 @@ summary({ 'GL' : dep_gl.found(), 'GLU' : dep_glu.found(), 'JSON-C' : dep_jsonc.found(), - 'Qt5' : [ - dep_qt5.found(), - have_qt5_opengl ? 'with QtGL' : 'without QtGL', + 'Qt5/Qt6' : [ + dep_qt.found(), + dep_qt_version + (have_qt_opengl ? ' with QtGL' : ' without QtGL'), ], 'SDL' : dep_sdl.found(), 'X11' : dep_x11.found(), diff --git a/utils/qv4l2/meson.build b/utils/qv4l2/meson.build index 4860e331..0216b258 100644 --- a/utils/qv4l2/meson.build +++ b/utils/qv4l2/meson.build @@ -1,4 +1,4 @@ -if get_option('qv4l2').disabled() or not dep_qt5.found() +if get_option('qv4l2').disabled() or not dep_qt.found() subdir_done() endif @@ -32,8 +32,8 @@ qv4l2_deps = [ dep_libv4l2, dep_libv4l2util, dep_libv4lconvert, - dep_qt5, - dep_qt5_opengl, + dep_qt, + dep_qt_opengl, dep_threads, ] @@ -42,16 +42,24 @@ qv4l2_incdir = [ v4l2_utils_incdir, ] -qt5_files = qt5.preprocess( - moc_headers : ['qv4l2.h', 'general-tab.h', 'vbi-tab.h', 'capture-win.h'], - qresources : 'qv4l2.qrc', -) -qv4l2_sources += qt5_files +if dep_qt6.found() + qt_files = qt6.preprocess( + moc_headers : ['qv4l2.h', 'general-tab.h', 'vbi-tab.h', 'capture-win.h'], + qresources : 'qv4l2.qrc', + ) +else + qt_files = qt5.preprocess( + moc_headers : ['qv4l2.h', 'general-tab.h', 'vbi-tab.h', 'capture-win.h'], + qresources : 'qv4l2.qrc', + ) +endif +qv4l2_sources += qt_files qv4l2 = executable('qv4l2', sources : qv4l2_sources, install : true, dependencies : qv4l2_deps, + override_options : dep_qt_options, include_directories : qv4l2_incdir) man_pages += [[ meson.current_source_dir(), 'qv4l2', 1 ]] diff --git a/utils/qvidcap/meson.build b/utils/qvidcap/meson.build index 63d76f29..16ca002e 100644 --- a/utils/qvidcap/meson.build +++ b/utils/qvidcap/meson.build @@ -1,10 +1,10 @@ qvidcap_option = get_option('qvidcap') -if qvidcap_option.enabled() and not have_qt5_opengl - error('qvidcap enabled but Qt5 is missing OpenGL support') +if qvidcap_option.enabled() and not have_qt_opengl + error('qvidcap enabled but Qt5/Qt6 is missing OpenGL support') endif -if qvidcap_option.disabled() or not dep_gl.found() or not dep_qt5_opengl.found() or not have_qt5_opengl +if qvidcap_option.disabled() or not dep_gl.found() or not dep_qt_opengl.found() or not have_qt_opengl subdir_done() endif @@ -29,8 +29,8 @@ qvidcap_deps = [ dep_libv4l2, dep_libv4l2util, dep_libv4lconvert, - dep_qt5, - dep_qt5_opengl, + dep_qt, + dep_qt_opengl, dep_threads, ] @@ -39,11 +39,18 @@ qvidcap_incdir = [ v4l2_utils_incdir, ] -qt5_files = qt5.preprocess( +if dep_qt6.found() +qt_files = qt6.preprocess( moc_headers : 'capture.h', qresources : 'qvidcap.qrc', ) -qvidcap_sources += qt5_files +else +qt_files = qt5.preprocess( + moc_headers : 'capture.h', + qresources : 'qvidcap.qrc', +) +endif +qvidcap_sources += qt_files v4l2_convert_sources = files( 'v4l2-convert.glsl', @@ -60,6 +67,7 @@ qvidcap = executable('qvidcap', sources : qvidcap_sources, install : true, dependencies : qvidcap_deps, + override_options : dep_qt_options, include_directories : qvidcap_incdir) man_pages += [[ meson.current_source_dir(), 'qvidcap', 1 ]] -- 2.43.0