meson: add build files for the qml plugin
[platform/upstream/gstreamer.git] / ext / qt / meson.build
1 sources = [
2   'gstplugin.cc',
3   'gstqsgtexture.cc',
4   'gstqtglutility.cc',
5   'gstqtsink.cc',
6   'gstqtsrc.cc',
7   'qtitem.cc',
8   'qtwindow.cc',
9 ]
10
11 moc_headers = [
12   'qtitem.h',
13   'qtwindow.h',
14   'gstqsgtexture.h',
15 ]
16
17 if have_cxx and build_gstgl
18   qt5_mod = import('qt5')
19   qt5qml_dep = dependency('qt5', modules : ['Core', 'Gui', 'Qml', 'Quick'], required: false)
20
21   # FIXME Add a way to get that information out of the qt5 module
22   moc = find_program('moc-qt5', required : false)
23   if qt5qml_dep.found() and moc.found()
24     optional_deps = []
25     qt_defines = []
26     have_qpa_include = false
27     have_qt_windowing = false
28
29     # Attempt to find the QPA header either through pkg-config (preferred) or qmake
30     # This semi-matches what meson does internally with the qt5 module
31     # FIXME Add a way to get some of this information out of the qt5 module
32     if not have_qpa_include
33       qt5core_dep = dependency('Qt5Core', required: false)
34       if qt5core_dep.found() and qt5core_dep.type_name() == 'pkgconfig'
35         qt_version = qt5core_dep.version()
36         qt_include_dir = qt5core_dep.get_pkgconfig_variable('includedir')
37         qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui')
38         if cxx.has_header('qpa/qplatformnativeinterface.h',
39                 dependencies : qt5core_dep,
40                 args : '-I' + qpa_include_path)
41           qt_defines += '-DHAVE_QT_QPA_HEADER'
42           qt_defines += '-I' + qpa_include_path
43           have_qpa_include = true
44           message('Found QPA header using pkg-config')
45         endif
46       endif
47     endif
48     if not have_qpa_include
49       qmake = find_program('qmake')
50       if qmake.found()
51         qt_version = run_command(qmake, '-query', 'QT_VERSION').stdout().strip()
52         qt_include_dir = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip()
53         qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui')
54         if cxx.has_header('qpa/qplatformnativeinterface.h',
55                 args : '-I' + qpa_include_path)
56           qt_defines += '-DHAVE_QT_QPA_HEADER'
57           qt_defines += '-I' + qpa_include_path
58           have_qpa_include = true
59           message('Found QPA header using qmake')
60         endif
61       endif
62     endif
63
64     # Try to come up with all the platform/winsys combinations that will work
65
66     if gst_gl_have_window_x11 and gst_gl_have_platform_glx
67       qt5x11extras = dependency('qt5', modules : ['X11Extras'], required : false)
68       if qt5x11extras.found()
69         optional_deps += qt5x11extras
70         qt_defines += ['-DHAVE_QT_X11']
71         have_qt_windowing = true
72       endif
73     endif
74
75     if gst_gl_have_platform_egl
76       if have_qpa_include
77         if gst_gl_have_window_wayland
78           qt5waylandextras = dependency('qt5', modules : ['WaylandClient'], required : false)
79           if qt5waylandextras.found()
80             optional_deps += qt5waylandextras
81             qt_defines += ['-DHAVE_QT_WAYLAND']
82             have_qt_windowing = true
83           endif
84         endif
85         if gst_gl_have_window_android
86           # FIXME: untested
87           qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], required : false)
88           if qt5androidextras.found()
89             optional_deps += qt5androidextras
90             # also uses the HAVE_QT_EGLFS define below
91             have_qt_windowing = true
92           endif
93         endif
94       endif
95       qt_defines += ['-DHAVE_QT_EGLFS']
96       have_qt_windowing = true
97     endif
98
99     if gst_gl_have_platform_wgl and gst_gl_have_window_win32
100           # for wglMakeCurrent()
101       opengl32_dep = cc.find_library('opengl32', required : false)
102       if opengl32_dep.found()
103         qt_defines += ['-DHAVE_QT_WIN32']
104                 optional_deps += opengl32_dep
105         have_qt_windowing = true
106           endif
107     endif
108
109     # FIXME: OSX/iOS definitions
110
111     if have_qt_windowing
112       # Build it!
113       moc_files = qt5_mod.preprocess(moc_headers : moc_headers)
114       library('gstqmlgl', sources, moc_files,
115         cpp_args : gst_plugins_good_args + qt_defines,
116         link_args : noseh_link_args,
117         include_directories: [configinc, libsinc],
118         dependencies : [glib_deps, gst_dep, gstvideo_dep, gstgl_dep, qt5qml_dep, optional_deps],
119         install: true,
120         install_dir : plugins_install_dir)
121     endif
122   endif
123 endif