meson/gl: use separate deps for gl and glx
authorMatthew Waters <matthew@centricular.com>
Fri, 9 Sep 2016 13:24:01 +0000 (23:24 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:32:22 +0000 (19:32 +0000)
e.g. passing with_gl_api=gles2 would still build the glx code but not be
linking against the libGL library which is where the glX* functions are
located and would result in a linker error.

Solved by checking for the libGL library if either opengl or glx may be
needed and then disabling the corresponding deps as requested.

gst-libs/gst/gl/meson.build

index f0e8bac..3db3875 100644 (file)
@@ -208,7 +208,8 @@ gl_include_header = '''
 
 # Desktop OpenGL checks
 gl_dep = unneeded_dep
-if need_api_opengl != 'no'
+glx_dep = unneeded_dep
+if need_api_opengl != 'no' and need_platform_glx != 'no'
   gl_dep = dependency('GL', required : false)
   if not gl_dep.found()
 #    if host_machine.system() == 'windows'
@@ -224,6 +225,14 @@ if need_api_opengl != 'no'
     endif
   endif
 
+  glx_dep = gl_dep
+  if need_api_opengl == 'no'
+    gl_dep = unneeded_dep
+  endif
+  if need_platform_glx == 'no'
+    glx_dep = unneeded_dep
+  endif
+
   opengl_includes = '''
 #ifdef __APPLE__
 # include <OpenGL/OpenGL.h>
@@ -423,13 +432,13 @@ if need_win_x11 != 'no'
     gl_winsys_deps += x11_dep
     enabled_gl_winsys += 'x11'
 
-    if need_platform_glx != 'no'
+    if need_platform_glx != 'no' and glx_dep.found()
       glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
       gl_sources += [
         'x11/gstglcontext_glx.c',
       ]
       # GLX is in the opengl library on linux
-      gl_platform_deps += gl_dep
+      gl_platform_deps += glx_dep
       enabled_gl_platforms += 'glx'
     endif
   elif need_win_x11 == 'yes'