Remove glib and gobject dependencies everywhere
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-good / ext / qt / meson.build
1 sources = [
2   'gstplugin.cc',
3   'gstqtelement.cc',
4   'gstqsgtexture.cc',
5   'gstqtglutility.cc',
6   'gstqtoverlay.cc',
7   'gstqtsink.cc',
8   'gstqtsrc.cc',
9   'qtglrenderer.cc',
10   'qtitem.cc',
11   'qtwindow.cc',
12 ]
13
14 moc_headers = [
15   'qtitem.h',
16   'qtwindow.h',
17   'gstqsgtexture.h',
18   'qtglrenderer.h',
19 ]
20
21 # Define a not-found dependency so this variable is always defined when we're
22 # deciding whether to build the qt5 examples
23 qt5qml_dep = dependency('', required: false)
24 qt5_option = get_option('qt5')
25
26 if qt5_option.disabled()
27   subdir_done()
28 endif
29
30 if not have_gstgl
31   if qt5_option.enabled()
32     error('qt5 qmlglsink plugin is enabled, but gstreamer-gl-1.0 was not found')
33   endif
34   subdir_done()
35 endif
36
37 if not add_languages('cpp', native: false, required: qt5_option)
38   subdir_done()
39 endif
40
41 qt5_mod = import('qt5')
42 qt5qml_dep = dependency('qt5', modules : ['Core', 'Gui', 'Qml', 'Quick'],
43                         required: qt5_option, static: host_machine.system() == 'ios')
44
45 # On Linux, distros often have the Qt5 pkg-config files and moc in separate
46 # packages, so the user may not have both installed. Check for moc and ensure
47 # that it's installed.
48 # We don't do this check on other OSes because they need to be able to simply
49 # point the `QMAKE` env var to `qmake` to build against a particular Qt5.
50 if host_system == 'linux' and not meson.is_cross_build()
51   moc = find_program('moc-qt5', 'moc', required : qt5_option)
52 else
53   # We only check if `moc` was found, and then discard it, so we can fake it.
54   # This is also a good unit test of the fact that we *don't* use it.
55   moc = declare_dependency()
56 endif
57
58 if not qt5qml_dep.found() or not moc.found()
59   subdir_done()
60 endif
61
62 optional_deps = []
63 qt_defines = []
64 have_qpa_include = false
65 have_qt_windowing = false
66
67 # Look for the QPA platform native interface header
68 qpa_header_path = join_paths(qt5qml_dep.version(), 'QtGui')
69 qpa_header = join_paths(qpa_header_path, 'qpa/qplatformnativeinterface.h')
70 if cxx.has_header(qpa_header, dependencies : qt5qml_dep)
71   qt_defines += '-DHAVE_QT_QPA_HEADER'
72   qt_defines += '-DQT_QPA_HEADER=' + '<@0@>'.format(qpa_header)
73   have_qpa_include = true
74   message('Found QtGui QPA header in ' + qpa_header_path)
75 endif
76
77 # Try to come up with all the platform/winsys combinations that will work
78
79 if gst_gl_have_window_x11 and gst_gl_have_platform_glx
80   # FIXME: automagic
81   qt5x11extras = dependency('qt5', modules : ['X11Extras'], required : false)
82   if qt5x11extras.found()
83     optional_deps += [qt5x11extras, gstglx11_dep]
84     qt_defines += ['-DHAVE_QT_X11']
85     have_qt_windowing = true
86   endif
87 endif
88
89 if gst_gl_have_platform_egl
90   # Embedded linux (e.g. i.MX6) with or without windowing support
91   qt_defines += ['-DHAVE_QT_EGLFS']
92   optional_deps += gstglegl_dep
93   have_qt_windowing = true
94   if have_qpa_include
95     # Wayland windowing
96     if gst_gl_have_window_wayland
97       # FIXME: automagic
98       qt5waylandextras = dependency('qt5', modules : ['WaylandClient'], required : false)
99       if qt5waylandextras.found()
100         optional_deps += [qt5waylandextras, gstglwayland_dep]
101         qt_defines += ['-DHAVE_QT_WAYLAND']
102         have_qt_windowing = true
103       endif
104     endif
105     # Android windowing
106     if gst_gl_have_window_android
107       # FIXME: automagic
108       qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], required : false)
109       # for gl functions in QtGui/qopenglfunctions.h
110       # FIXME: automagic
111       glesv2_dep = cc.find_library('GLESv2', required : false)
112       if glesv2_dep.found() and qt5androidextras.found()
113         optional_deps += [qt5androidextras, glesv2_dep]
114         qt_defines += ['-DHAVE_QT_ANDROID']
115         have_qt_windowing = true
116         # Needed for C++11 support in Cerbero. People building with Android
117         # in some other way need to add the necessary bits themselves.
118         optional_deps += dependency('gnustl', required : false)
119       endif
120     endif
121   endif
122 endif
123
124 if gst_gl_have_platform_wgl and gst_gl_have_window_win32
125   # for wglMakeCurrent()
126   # FIXME: automagic
127   opengl32_dep = cc.find_library('opengl32', required : false)
128   if opengl32_dep.found()
129     qt_defines += ['-DHAVE_QT_WIN32']
130     optional_deps += opengl32_dep
131     have_qt_windowing = true
132   endif
133 endif
134
135 if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl
136   # FIXME: automagic
137   qt5macextras = dependency('qt5', modules : ['MacExtras'], required : false)
138   if qt5macextras.found()
139     qt_defines += ['-DHAVE_QT_MAC']
140     optional_deps += qt5macextras
141     have_qt_windowing = true
142   endif
143 endif
144
145 if gst_gl_have_window_eagl and gst_gl_have_platform_eagl
146   if host_machine.system() == 'ios'
147     qt_defines += ['-DHAVE_QT_IOS']
148     have_qt_windowing = true
149   endif
150 endif
151
152 if have_qt_windowing
153   # Build it!
154   moc_files = qt5_mod.preprocess(moc_headers : moc_headers)
155   gstqmlgl = library('gstqmlgl', sources, moc_files,
156     cpp_args : gst_plugins_good_args + qt_defines,
157     link_args : noseh_link_args,
158     include_directories: [configinc, libsinc],
159     dependencies : [gst_dep, gstvideo_dep, gstgl_dep, gstglproto_dep, qt5qml_dep, optional_deps],
160     override_options : ['cpp_std=c++11'],
161     install: true,
162     install_dir : plugins_install_dir)
163   pkgconfig.generate(gstqmlgl, install_dir : plugins_pkgconfig_install_dir)
164   plugins += [gstqmlgl]
165 endif