meson: Fix indentation in qt plugin and add a FIXME comment
[platform/upstream/gst-plugins-good.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 # FIXME: -Dqt5=enabled is silently ignored if a c++ compiler is not found
18 if have_cxx and build_gstgl
19   qt5_mod = import('qt5')
20   qt5qml_dep = dependency('qt5', modules : ['Core', 'Gui', 'Qml', 'Quick'],
21                           required: get_option('qt5'))
22
23   # FIXME Add a way to get that information out of the qt5 module
24   moc = find_program('moc-qt5', 'moc', required : get_option('qt5'))
25   if qt5qml_dep.found() and moc.found()
26     optional_deps = []
27     qt_defines = []
28     have_qpa_include = false
29     have_qt_windowing = false
30
31     # Attempt to find the QPA header either through pkg-config (preferred) or qmake
32     # This semi-matches what meson does internally with the qt5 module
33     # FIXME Add a way to get some of this information out of the qt5 module
34     if not have_qpa_include
35       # FIXME: automagic
36       qt5core_dep = dependency('Qt5Core', required: false)
37       if qt5core_dep.found() and qt5core_dep.type_name() == 'pkgconfig'
38         qt_version = qt5core_dep.version()
39         qt_include_dir = qt5core_dep.get_pkgconfig_variable('includedir')
40         qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui')
41         if cxx.has_header('qpa/qplatformnativeinterface.h',
42                 dependencies : qt5core_dep,
43                 args : '-I' + qpa_include_path)
44           qt_defines += '-DHAVE_QT_QPA_HEADER'
45           qt_defines += '-I' + qpa_include_path
46           have_qpa_include = true
47           message('Found QPA header using pkg-config')
48         endif
49       endif
50     endif
51     if not have_qpa_include
52       qmake = find_program('qmake-qt5', 'qmake')
53       if qmake.found()
54         qt_version = run_command(qmake, '-query', 'QT_VERSION').stdout().strip()
55         qt_include_dir = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip()
56         qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui')
57         if cxx.has_header('qpa/qplatformnativeinterface.h',
58                 args : '-I' + qpa_include_path)
59           qt_defines += '-DHAVE_QT_QPA_HEADER'
60           qt_defines += '-I' + qpa_include_path
61           have_qpa_include = true
62           message('Found QPA header using qmake')
63         endif
64       endif
65     endif
66
67     # Try to come up with all the platform/winsys combinations that will work
68
69     if gst_gl_have_window_x11 and gst_gl_have_platform_glx
70       # FIXME: automagic
71       qt5x11extras = dependency('qt5', modules : ['X11Extras'], required : false)
72       if qt5x11extras.found()
73         optional_deps += qt5x11extras
74         qt_defines += ['-DHAVE_QT_X11']
75         have_qt_windowing = true
76       endif
77     endif
78
79     if gst_gl_have_platform_egl
80       # Embedded linux (e.g. i.MX6) with or without windowing support
81       qt_defines += ['-DHAVE_QT_EGLFS']
82       have_qt_windowing = true
83       if have_qpa_include
84         # Wayland windowing
85         if gst_gl_have_window_wayland
86           # FIXME: automagic
87           qt5waylandextras = dependency('qt5', modules : ['WaylandClient'], required : false)
88           if qt5waylandextras.found()
89             optional_deps += qt5waylandextras
90             qt_defines += ['-DHAVE_QT_WAYLAND']
91             have_qt_windowing = true
92           endif
93         endif
94         # Android windowing
95         if gst_gl_have_window_android
96           # FIXME: automagic
97           qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], required : false)
98           # for gl functions in QtGui/qopenglfunctions.h
99           # FIXME: automagic
100           glesv2_dep = cc.find_library('GLESv2', required : false)
101           if glesv2_dep.found() and qt5androidextras.found()
102             optional_deps += [qt5androidextras, glesv2_dep]
103             qt_defines += ['-DHAVE_QT_ANDROID']
104             have_qt_windowing = true
105             # Needed for C++11 support in Cerbero. People building with Android
106             # in some other way need to add the necessary bits themselves.
107             optional_deps += dependency('gnustl', required : false)
108           endif
109         endif
110       endif
111     endif
112
113     if gst_gl_have_platform_wgl and gst_gl_have_window_win32
114       # for wglMakeCurrent()
115       # FIXME: automagic
116       opengl32_dep = cc.find_library('opengl32', required : false)
117       if opengl32_dep.found()
118         qt_defines += ['-DHAVE_QT_WIN32']
119         optional_deps += opengl32_dep
120         have_qt_windowing = true
121       endif
122     endif
123
124     # FIXME: iOS definitions
125     if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl
126       # FIXME: automagic
127       qt5macextras = dependency('qt5', modules : ['MacExtras'], required : false)
128       if qt5macextras.found()
129         qt_defines += ['-DHAVE_QT_MAC']
130         optional_deps += qt5macextras
131         have_qt_windowing = true
132       endif
133     endif
134
135     if have_qt_windowing
136       # Build it!
137       moc_files = qt5_mod.preprocess(moc_headers : moc_headers)
138       gstqmlgl = library('gstqmlgl', sources, moc_files,
139         cpp_args : gst_plugins_good_args + qt_defines,
140         link_args : noseh_link_args,
141         include_directories: [configinc, libsinc],
142         dependencies : [glib_deps, gst_dep, gstvideo_dep, gstgl_dep, qt5qml_dep, optional_deps],
143         install: true,
144         install_dir : plugins_install_dir)
145       pkgconfig.generate(gstqmlgl, install_dir : plugins_pkgconfig_install_dir)
146     endif
147   endif
148 endif