4ab5c57f3c0886c26f67d0641e52a0bb1ce009c2
[platform/upstream/gstreamer.git] / gst-libs / gst / gl / meson.build
1 gl_sources = [
2   'gstglapi.c',
3   'gstglbasefilter.c',
4   'gstglbasememory.c',
5   'gstglcolorconvert.c',
6   'gstglbuffer.c',
7   'gstglbufferpool.c',
8   'gstglcontext.c',
9   'gstgldebug.c',
10   'gstgldisplay.c',
11   'gstglfeature.c',
12   'gstglfilter.c',
13   'gstglformat.c',
14   'gstglframebuffer.c',
15   'gstglmemory.c',
16   'gstglmemorypbo.c',
17   'gstgloverlaycompositor.c',
18   'gstglquery.c',
19   'gstglrenderbuffer.c',
20   'gstglshader.c',
21   'gstglshaderstrings.c',
22   'gstglsl.c',
23   'gstglslstage.c',
24   'gstglsyncmeta.c',
25   'gstglupload.c',
26   'gstglutils.c',
27   'gstglviewconvert.c',
28   'gstglwindow.c',
29 ]
30
31 gl_headers = [
32   'gl.h',
33   'gl-prelude.h',
34   'gstgl_enums.h',
35   'gstgl_fwd.h',
36   'gstglapi.h',
37   'gstglbasefilter.h',
38   'gstglbasememory.h',
39   'gstglbuffer.h',
40   'gstglbufferpool.h',
41   'gstglcolorconvert.h',
42   'gstglcontext.h',
43   'gstgldebug.h',
44   'gstgldisplay.h',
45   'gstglfeature.h',
46   'gstglfilter.h',
47   'gstglformat.h',
48   'gstglfuncs.h',
49   'gstglframebuffer.h',
50   'gstglmemory.h',
51   'gstglmemorypbo.h',
52   'gstgloverlaycompositor.h',
53   'gstglquery.h',
54   'gstglrenderbuffer.h',
55   'gstglshader.h',
56   'gstglshaderstrings.h',
57   'gstglsl.h',
58   'gstglslstage.h',
59   'gstglsyncmeta.h',
60   'gstglupload.h',
61   'gstglutils.h',
62   'gstglviewconvert.h',
63   'gstglwindow.h',
64 ]
65
66 gl_prototype_headers = [
67   'glprototypes/all_functions.h',
68   'glprototypes/base.h',
69   'glprototypes/blending.h',
70   'glprototypes/buffers.h',
71   'glprototypes/debug.h',
72   'glprototypes/eglimage.h',
73   'glprototypes/fbo.h',
74   'glprototypes/fixedfunction.h',
75   'glprototypes/gles.h',
76   'glprototypes/gstgl_compat.h',
77   'glprototypes/gstgl_gles2compat.h',
78   'glprototypes/Makefile.am',
79   'glprototypes/opengl.h',
80   'glprototypes/query.h',
81   'glprototypes/README',
82   'glprototypes/shaders.h',
83   'glprototypes/sync.h',
84   'glprototypes/vao.h',
85 ]
86
87 gl_x11_headers = []
88 gl_wayland_headers = []
89 gl_win32_headers = []
90 gl_cocoa_headers = []
91 gl_egl_headers = []
92
93 glconf = configuration_data()
94 glconf_options = [
95     'GST_GL_HAVE_OPENGL',
96     'GST_GL_HAVE_GLES2',
97     'GST_GL_HAVE_GLES3',
98     'GST_GL_HAVE_GLES3EXT3_H',
99
100     'GST_GL_HAVE_WINDOW_X11',
101     'GST_GL_HAVE_WINDOW_COCOA',
102     'GST_GL_HAVE_WINDOW_WIN32',
103     'GST_GL_HAVE_WINDOW_WAYLAND',
104     'GST_GL_HAVE_WINDOW_ANDROID',
105     'GST_GL_HAVE_WINDOW_DISPMANX',
106     'GST_GL_HAVE_WINDOW_EAGL',
107     'GST_GL_HAVE_WINDOW_VIV_FB',
108     'GST_GL_HAVE_WINDOW_GBM',
109
110     'GST_GL_HAVE_PLATFORM_EGL',
111     'GST_GL_HAVE_PLATFORM_GLX',
112     'GST_GL_HAVE_PLATFORM_WGL',
113     'GST_GL_HAVE_PLATFORM_CGL',
114     'GST_GL_HAVE_PLATFORM_EAGL',
115
116     'GST_GL_HAVE_DMABUF',
117     'GST_GL_HAVE_VIV_DIRECTVIV',
118
119     'GST_GL_HAVE_GLEGLIMAGEOES',
120     'GST_GL_HAVE_GLCHAR',
121     'GST_GL_HAVE_GLSIZEIPTR',
122     'GST_GL_HAVE_GLINTPTR',
123     'GST_GL_HAVE_GLSYNC',
124     'GST_GL_HAVE_GLUINT64',
125     'GST_GL_HAVE_GLINT64',
126     'GST_GL_HAVE_EGLATTRIB',
127 ]
128
129 foreach option : glconf_options
130   glconf.set10(option, false)
131 endforeach
132
133 gmodule_dep = dependency('gmodule-no-export-2.0',
134   fallback: ['glib', 'libgmodule_dep'])
135 unneeded_dep = dependency('', required : false)
136 if unneeded_dep.found()
137   error ('Found unfindable dependency')
138 endif
139
140 # OpenGL/GLES2 libraries
141 gl_lib_deps = []
142 # GL platform - EGL, GLX, CGL, WGL, etc
143 gl_platform_deps = []
144 # GL winsys - wayland, X11, Cocoa, win32, etc
145 gl_winsys_deps = []
146 # other things we need.
147 gl_misc_deps = []
148 # Other preprocessor arguments
149 gl_cpp_args = ['-DGST_EXPORTS']
150
151 enabled_gl_apis = []
152 enabled_gl_platforms = []
153 enabled_gl_winsys = []
154
155 # parse provided options
156 libegl_module_name = get_option('with_egl_module_name')
157 if libegl_module_name != ''
158   gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
159 endif
160 libgles2_module_name = get_option('with_gles2_module_name')
161 if libgles2_module_name != ''
162   gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
163 endif
164 libgl_module_name = get_option('with_opengl_module_name')
165 if libgl_module_name != ''
166   gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
167 endif
168
169 gl_apis_s = get_option ('with_gl_api')
170 if gl_apis_s == 'auto'
171   need_api_opengl = 'auto'
172   need_api_gles2 = 'auto'
173 else
174   need_api_opengl = 'no'
175   need_api_gles2 = 'no'
176   gl_apis = gl_apis_s.split(',')
177   foreach api : gl_apis
178     if api == 'opengl'
179       need_api_opengl = 'yes'
180     elif api == 'gles2'
181       need_api_gles2 = 'yes'
182     else
183       error('Unsupported GL api provided ' + api)
184     endif
185   endforeach
186 endif
187
188 gl_platforms_s = get_option ('with_gl_platform')
189 if gl_platforms_s == 'auto'
190   need_platform_egl = 'auto'
191   need_platform_glx = 'auto'
192   need_platform_cgl = 'auto'
193   need_platform_wgl = 'auto'
194   need_platform_eagl = 'auto'
195 else
196   need_platform_egl = 'no'
197   need_platform_glx = 'no'
198   need_platform_cgl = 'no'
199   need_platform_wgl = 'no'
200   need_platform_eagl = 'no'
201   gl_platforms = gl_platforms_s.split(',')
202   foreach platform : gl_platforms
203     if platform == 'egl'
204       need_platform_egl = 'yes'
205     elif platform == 'glx'
206       need_platform_glx = 'yes'
207 #    elif platform == 'cgl'
208 #      need_platform_cgl = 'yes'
209     elif platform == 'wgl'
210       need_platform_wgl = 'yes'
211 #    elif platform == 'eagl'
212 #      need_platform_eagl = 'yes'
213     else
214       error('Unsupported GL platform provided ' + platform)
215     endif
216   endforeach
217 endif
218
219 gl_winsys_s = get_option ('with_gl_winsys')
220 if gl_winsys_s == 'auto'
221   need_win_x11 = 'auto'
222   need_win_wayland = 'auto'
223   need_win_win32 = 'auto'
224   need_win_cocoa = 'auto'
225   need_win_eagl = 'auto'
226   need_win_dispmanx = 'auto'
227   need_win_viv_fb = 'auto'
228   need_win_gbm = 'auto'
229 else
230   need_win_x11 = 'no'
231   need_win_wayland = 'no'
232   need_win_win32 = 'no'
233   need_win_cocoa = 'no'
234   need_win_eagl = 'no'
235   need_win_dispmanx = 'no'
236   need_win_viv_fb = 'no'
237   need_win_gbm = 'no'
238   gl_winsys = gl_winsys_s.split(',')
239   foreach winsys : gl_winsys
240     if winsys == 'x11'
241       need_win_x11 = 'yes'
242     elif winsys == 'wayland'
243       need_win_wayland = 'yes'
244     elif winsys == 'win32'
245       need_win_win32 = 'yes'
246 #    elif winsys == 'cocoa'
247 #      need_win_cocoa = 'yes'
248 #    elif winsys == 'eagl'
249 #      need_win_eagl = 'yes'
250     elif winsys == 'dispmanx'
251       need_win_dispmanx = 'yes'
252     elif winsys == 'viv-fb'
253       need_win_viv_fb = 'yes'
254     elif winsys == 'gbm'
255       need_win_gbm = 'no'
256     else
257       error('Unsupported GL winsys provided ' + winsys)
258     endif
259   endforeach
260 endif
261
262 gl_include_header = '''
263 #ifdef __GNUC__
264 #  pragma GCC diagnostic push
265 #  pragma GCC diagnostic ignored "-Wredundant-decls"
266 #endif
267 #ifndef GL_GLEXT_PROTOTYPES
268 #define GL_GLEXT_PROTOTYPES 1
269 #endif
270 '''
271
272 # Desktop OpenGL checks
273 gl_dep = unneeded_dep
274 glx_dep = unneeded_dep
275 if need_api_opengl != 'no' or need_platform_glx != 'no'
276   gl_dep = dependency('gl', required : false)
277   if not gl_dep.found()
278     if host_machine.system() == 'windows'
279       gl_dep = cc.find_library('opengl32', required : false)
280 #    elif host_machine.system() == 'darwin'
281 #      gl_dep = cc.find_library('OpenGL', required : false)
282     else
283       gl_dep = cc.find_library('GL', required : false)
284     endif
285
286     if not cc.has_header('GL/gl.h')
287       gl_dep = unneeded_dep
288     endif
289
290     if not gl_dep.found() and need_api_opengl == 'yes'
291       error ('Could not find requested OpenGL library')
292     endif
293   endif
294
295   glx_dep = gl_dep
296   if need_api_opengl == 'no'
297     gl_dep = unneeded_dep
298   endif
299   if need_platform_glx == 'no'
300     glx_dep = unneeded_dep
301   endif
302
303   opengl_includes = '''
304 #ifdef __APPLE__
305 # include <OpenGL/OpenGL.h>
306 # include <OpenGL/gl.h>
307 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
308 #  define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
309 #  include <OpenGL/gl3.h>
310 # endif
311 #else
312 # if _MSC_VER
313 #  include <windows.h>
314 # endif
315 # include <GL/gl.h>
316 # if __WIN32__ || _WIN32
317 #  include <GL/glext.h>
318 # endif
319 #endif
320 '''
321 endif
322
323 # GLES2 checks
324 gles2_dep = unneeded_dep
325 gles3_h = false
326 gles3ext3_h = false
327 if need_api_gles2 != 'no'
328   gles2_dep = dependency('glesv2', required : false)
329   if not gles2_dep.found()
330 #    if host_machine.system() == 'windows'
331 #    elif host_machine.system() == 'darwin'
332 #      gles2_dep = cc.find_library('GLESv2', required : false)
333 #    else
334       gles2_dep = cc.find_library('GLESv2', required : false)
335 #    endif
336
337      if not cc.has_header('GLES2/gl2.h')
338        gles2_dep = unneeded_dep
339      endif
340
341     if not gles2_dep.found() and need_api_gles2 == 'yes'
342       error ('Could not find requested OpenGL ES library')
343     endif
344   endif
345
346   gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep)
347
348   gles_includes = '''
349 #ifdef HAVE_IOS /* FIXME */
350 # include <OpenGLES/ES2/gl.h>
351 # include <OpenGLES/ES2/glext.h>
352 #else'''
353   if gles3_h
354     gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep)
355     gles_includes += '''
356 # include <GLES3/gl3.h>
357 # include <GLES2/gl2ext.h>'''
358     if gles3ext3_h
359       gles_includes += '''
360 # include <GLES3/gl3ext.h>'''
361     endif
362   else
363     gles_includes += '''
364 # include <GLES2/gl2.h>
365 # include <GLES2/gl2ext.h>'''
366   endif
367   gles_includes += '''
368 #endif
369 '''
370 endif
371
372 # can we include both gles2 and opengl headers?
373 if gles2_dep.found() and gl_dep.found()
374   gl_include_block = gl_include_header + gles_includes + opengl_includes
375   # TODO: Revert to passing gl_include_block via prefix: once
376   # https://github.com/mesonbuild/meson/issues/2364 is fixed
377   if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep])
378     message ('Cannot include both OpenGL and OpenGL ES headers')
379     if need_api_gles2 != 'yes'
380       gles2_dep = unneeded_dep
381     elif need_api_opengl != 'yes'
382       gl_dep = unneeded_dep
383     else
384       error('Both OpenGL and OpenGL ES were requested but cannot be included together')
385     endif
386   endif
387 endif
388 gl_include_block = gl_include_header
389 if gles2_dep.found()
390   gl_include_block += gles_includes
391 endif
392 if gl_dep.found()
393   gl_include_block += opengl_includes
394 endif
395
396 if gles2_dep.found()
397   gl_lib_deps += gles2_dep
398   glconf.set10('GST_GL_HAVE_GLES2', 1)
399   if gles3_h
400     glconf.set10('GST_GL_HAVE_GLES3', 1)
401     if gles3ext3_h
402       glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
403     endif
404   endif
405   enabled_gl_apis += 'gles2'
406 endif
407
408 if gl_dep.found()
409   gl_lib_deps += gl_dep
410   glconf.set10('GST_GL_HAVE_OPENGL', 1)
411   enabled_gl_apis += 'opengl'
412 endif
413
414 # EGL checks
415 egl_dep = unneeded_dep
416 if need_platform_egl != 'no'
417   egl_dep = dependency('egl', required : false)
418   if not egl_dep.found()
419     egl_dep = cc.find_library('EGL', required : false)
420
421     if not egl_dep.found() and need_platform_egl == 'yes'
422       error ('Could not find requested EGL library')
423     endif
424   endif
425
426   if egl_dep.found()
427     gl_sources += [
428       'egl/gstegl.c',
429       'egl/gsteglimage.c',
430       'egl/gstglcontext_egl.c',
431       'egl/gstgldisplay_egl.c',
432       'egl/gstglmemoryegl.c',
433     ]
434     gl_egl_headers += [
435       'egl/gstegl.h',
436       'egl/gsteglimage.h',
437       'egl/gstgldisplay_egl.h',
438       'egl/gstglmemoryegl.h',
439     ]
440     gl_platform_deps += egl_dep
441     glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
442
443     if cc.has_header('libdrm/drm_fourcc.h')
444       gl_misc_deps += allocators_dep
445       glconf.set10('GST_GL_HAVE_DMABUF', 1)
446     endif
447
448     egl_includes = '''
449 #include <EGL/egl.h>
450 #include <EGL/eglext.h>
451 '''
452     enabled_gl_platforms += 'egl'
453   endif
454
455 endif
456
457 # wayland checks
458 wayland_client_dep = unneeded_dep
459 wayland_cursor_dep = unneeded_dep
460 wayland_egl_dep = unneeded_dep
461 if need_win_wayland != 'no'
462   if need_win_wayland == 'yes'
463     if need_platform_egl == 'no'
464       error('Impossible situation requested: Cannot use Wayland without EGL support')
465     endif
466   endif
467   if not egl_dep.found()
468     if need_win_wayland == 'yes'
469       error ('Could not find EGL libraries for wayland')
470     else
471       message ('Could not find EGL libraries for wayland')
472     endif
473   else
474     wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false)
475     wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
476     wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
477
478     if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found()
479       gl_sources += [
480         'wayland/gstgldisplay_wayland.c',
481         'wayland/gstglwindow_wayland_egl.c',
482         'wayland/wayland_event_source.c',
483       ]
484       gl_wayland_headers += [
485         'wayland/gstgldisplay_wayland.h'
486       ]
487       glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
488       gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
489       enabled_gl_winsys += 'wayland'
490     else
491       if need_win_wayland == 'yes'
492         error ('Could not find requested Wayland libraries')
493       endif
494       wayland_client_dep = unneeded_dep
495       wayland_cursor_dep = unneeded_dep
496       wayland_egl_dep = unneeded_dep
497     endif
498   endif
499 endif
500
501 # X11 checks
502 if need_platform_glx == 'yes'
503   if need_win_x11 == 'no'
504     error('Impossible situation requested: Cannot use GLX without X11 support')
505   elif need_api_opengl == 'no'
506     error('Impossible situation requested: Cannot use GLX without the OpenGL library')
507   endif
508 endif
509
510 if need_win_x11 != 'no'
511   xcb_dep = dependency('x11-xcb', required : false)
512   if x11_dep.found() and xcb_dep.found()
513     gl_sources += [
514       'x11/gstgldisplay_x11.c',
515       'x11/gstglwindow_x11.c',
516       'x11/xcb_event_source.c',
517     ]
518     gl_x11_headers += [
519       'x11/gstgldisplay_x11.h',
520     ]
521     glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
522     gl_winsys_deps += [x11_dep, xcb_dep]
523     enabled_gl_winsys += 'x11'
524
525     if need_platform_glx != 'no' and glx_dep.found()
526       glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
527       gl_sources += [
528         'x11/gstglcontext_glx.c',
529       ]
530       # GLX is in the opengl library on linux
531       gl_platform_deps += glx_dep
532       enabled_gl_platforms += 'glx'
533     endif
534   elif need_win_x11 == 'yes'
535     error ('Could not find requested X11 libraries')
536   endif
537 endif
538
539 bcm_host_dep = unneeded_dep
540 if need_win_dispmanx != 'no'
541
542   # Try pkg-config for bcm_host then fallback to find_library to also
543   # support older distribution
544   bcm_host_dep = dependency('bcm_host', required : false)
545   if not bcm_host_dep.found()
546     bcm_host_dep = cc.find_library('bcm_host', required : false)
547   endif
548
549   if bcm_host_dep.found()
550     if not egl_dep.found()
551       error('dispmanx requires the use of egl')
552     endif
553
554     gl_sources += [
555       'dispmanx/gstglwindow_dispmanx_egl.c'
556     ]
557
558     glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
559     gl_winsys_deps += bcm_host_dep
560     enabled_gl_winsys += 'dispmanx'
561     gl_cpp_args += ['-DUSE_EGL_RPI']
562   elif need_win_dispmanx == 'yes'
563     error('Could not find dispmanx libraries')
564   endif
565 endif
566
567 # win32 checks
568 if need_platform_wgl == 'yes'
569   if need_win_win32 == 'no'
570     error('Impossible situation requested: Cannot use WGL without the win32 window system')
571   endif
572 endif
573
574 # XXX: untested
575 if need_platform_wgl != 'no' and need_win_win32 != 'no'
576   gdi_dep = cc.find_library('gdi32', required : false)
577   # FIXME: Revert back to has_header once it gains prefix support
578   wglext_h = cc.has_header_symbol('GL/wglext.h', 'WGL_WGLEXT_VERSION',
579                                   prefix : '''#include <windows.h>
580                                               #include <GL/gl.h>''')
581
582   if wglext_h and gdi_dep.found() and gl_dep.found()
583     gl_platform_deps += gdi_dep
584     gl_sources += [
585       'win32/win32_message_source.c',
586       'win32/gstglwindow_win32.c',
587       'win32/gstglwindow_win32.c',
588       'win32/gstglcontext_wgl.c',
589     ]
590     enabled_gl_winsys += 'win32'
591     gl_winsys_deps += gdi_dep
592     enabled_gl_platforms += 'wgl'
593     glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
594     glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
595   endif
596 endif
597
598 if host_machine.system() == 'darwin'
599   # FIXME: how to know if we're on iOS or OS X?
600 #  gl_cocoa_headers += [
601 #    'gstglcontext_cocoa.h',
602 #    'gstglcaopengllayer.h',
603 #  ]
604 endif
605
606 # GDM Checks
607 gbm_gudev_dep = unneeded_dep
608 gbm_libdrm_dep = unneeded_dep
609 gbm_dep = unneeded_dep
610 if need_win_gbm != 'no'
611   if need_win_gbm == 'yes'
612     if need_platform_egl == 'no'
613       error('Impossible situation requested: Cannot use GBM without EGL support')
614     endif
615   endif
616
617   gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
618   gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
619   gbm_dep = dependency('gbm', required : false)
620   if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
621     gl_sources += [
622       'gbm/gstgldisplay_gbm.c',
623       'gbm/gstgl_gbm_utils.c',
624       'gbm/gstglwindow_gbm_egl.c',
625     ]
626     enabled_gl_winsys += 'gbm'
627     gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
628     glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
629   else
630     if need_win_gbm == 'yes'
631       error ('Could not find requested GBM libraries')
632     endif
633     gbm_gudev_dep = unneeded_dep
634     gbm_libdrm_dep = unneeded_dep
635     gbm_dep = unneeded_dep
636   endif
637 endif
638
639 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
640   if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
641     if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
642       enabled_gl_winsys += 'viv-fb'
643       glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
644       glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
645       gl_sources += [
646         'viv-fb/gstgldisplay_viv_fb.c',
647         'viv-fb/gstglwindow_viv_fb_egl.c',
648       ]
649       gl_cpp_args += ['-DEGL_API_FB']
650     endif
651   endif
652 endif
653
654 # TODO: Add rest of gl config here.
655 # iOS, OS X, win32 specific support
656
657 build_gstgl = true
658 if enabled_gl_apis.length() == 0
659   message('No OpenGL API libraries found or requested')
660   build_gstgl = false
661 endif
662 if enabled_gl_platforms.length() == 0
663   message('No OpenGL Platforms found or requested')
664   build_gstgl = false
665 endif
666 if enabled_gl_winsys.length() == 0
667   message('No OpenGL Window systems found or requested')
668   build_gstgl = false
669 endif
670
671 if build_gstgl
672   # find some types that may or may not be defined
673   if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps)
674     glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
675   endif
676   if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps)
677     glconf.set('GST_GL_HAVE_GLCHAR', 1)
678   endif
679   if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps)
680     glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
681   endif
682   if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps)
683     glconf.set('GST_GL_HAVE_GLINTPTR', 1)
684   endif
685   if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps)
686     glconf.set('GST_GL_HAVE_GLSYNC', 1)
687   endif
688   if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps)
689     glconf.set('GST_GL_HAVE_GLUINT64', 1)
690   endif
691   if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps)
692     glconf.set('GST_GL_HAVE_GLINT64', 1)
693   endif
694   if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep])
695     glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
696   endif
697
698   message('Building libgstgl with GL api:      ' + ' '.join(enabled_gl_apis))
699   message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
700   message('Building libgstgl with GL winsys:   ' + ' '.join(enabled_gl_winsys))
701
702   install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
703   install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa')
704   install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
705   install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
706   install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
707   install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
708
709   configure_file(input : 'gstglconfig.h.meson',
710     output : 'gstglconfig.h',
711     install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
712     configuration : glconf)
713
714   gstgl = library('gstgl-' + api_version,
715     gl_sources,
716     c_args : gst_plugins_base_args + gl_cpp_args,
717     include_directories : [configinc, libsinc],
718     version : libversion,
719     soversion : soversion,
720     install : true,
721     dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
722                     gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
723   gen_sources = []
724   if build_gir
725     gl_gir = gnome.generate_gir(gstgl,
726       sources : gl_sources + gl_headers,
727       namespace : 'GstGL',
728       nsversion : api_version,
729       identifier_prefix : 'Gst',
730       symbol_prefix : 'gst',
731       export_packages : 'gstreamer-gl-1.0',
732       includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
733       install : true,
734       extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
735       dependencies : [video_dep, gst_dep, gst_base_dep]
736     )
737     gen_sources += gl_gir
738   endif
739
740
741   gstgl_dep = declare_dependency(link_with : gstgl,
742     include_directories : [libsinc],
743     sources: gen_sources,
744     dependencies : [video_dep, gst_base_dep] + gl_winsys_deps)
745 endif