qt: Rework how we find the Qt QPA header
authorNirbheek Chauhan <nirbheek@centricular.com>
Wed, 24 Jun 2020 16:28:07 +0000 (21:58 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Sat, 27 Jun 2020 18:46:53 +0000 (00:16 +0530)
Instead of querying the Qt include path from the dependency or from
qmake, rely on the qt5qml_dep to set the include path to QtGui
correctly, and look for the header inside the private includedir.

Then we can use that path to include the header directly.

Reported in https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/780#note_548092

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/640>

ext/qt/gstqtglutility.cc
ext/qt/meson.build

index 7c7e8e1..acb89b6 100644 (file)
@@ -34,7 +34,7 @@
 #if GST_GL_HAVE_PLATFORM_EGL && (defined (HAVE_QT_WAYLAND) || defined (HAVE_QT_EGLFS) || defined (HAVE_QT_ANDROID))
 #include <gst/gl/egl/gstegl.h>
 #ifdef HAVE_QT_QPA_HEADER
-#include <qpa/qplatformnativeinterface.h>
+#include QT_QPA_HEADER
 #endif
 #include <QtPlatformHeaders/QEGLNativeContext>
 #include <gst/gl/egl/gstgldisplay_egl.h>
index 38b8a25..e342f64 100644 (file)
@@ -63,40 +63,14 @@ qt_defines = []
 have_qpa_include = false
 have_qt_windowing = false
 
-# Attempt to find the QPA header either through pkg-config (preferred) or qmake
-# This semi-matches what meson does internally with the qt5 module
-# FIXME Add a way to get some of this information out of the qt5 module
-if not have_qpa_include
-  # FIXME: automagic
-  qt5core_dep = dependency('Qt5Core', required: false)
-  if qt5core_dep.found() and qt5core_dep.type_name() == 'pkgconfig'
-    qt_version = qt5core_dep.version()
-    qt_include_dir = qt5core_dep.get_pkgconfig_variable('includedir')
-    qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui')
-    if cxx.has_header('qpa/qplatformnativeinterface.h',
-            dependencies : qt5core_dep,
-            args : '-I' + qpa_include_path)
-      qt_defines += '-DHAVE_QT_QPA_HEADER'
-      qt_defines += '-I' + qpa_include_path
-      have_qpa_include = true
-      message('Found QPA header using pkg-config')
-    endif
-  endif
-endif
-if not have_qpa_include
-  qmake = find_program('qmake-qt5', 'qmake')
-  if qmake.found()
-    qt_version = run_command(qmake, '-query', 'QT_VERSION').stdout().strip()
-    qt_include_dir = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip()
-    qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui')
-    if cxx.has_header('qpa/qplatformnativeinterface.h',
-            args : '-I' + qpa_include_path)
-      qt_defines += '-DHAVE_QT_QPA_HEADER'
-      qt_defines += '-I' + qpa_include_path
-      have_qpa_include = true
-      message('Found QPA header using qmake')
-    endif
-  endif
+# 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)
+  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