gl: Try GLVND 'opengl' and 'glx' first
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 14 May 2021 12:10:55 +0000 (14:10 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 13 Jul 2021 13:42:13 +0000 (13:42 +0000)
This fixes targetting desktop OpenGL without libGL.so

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1143>

gst-libs/gst/gl/meson.build

index 7694883..bfaaf1d 100644 (file)
@@ -309,7 +309,14 @@ endif
 # Desktop OpenGL checks
 gl_dep = unneeded_dep
 glx_dep = unneeded_dep
-if need_api_opengl != 'no' or need_platform_glx != 'no'
+
+# (GLVND) OpenGL (without GLX) headers and interface
+if need_api_opengl != 'no'
+  gl_dep = dependency('opengl', method: 'pkg-config', required : false)
+endif
+
+# non-GLVND aka Legacy OpenGL
+if need_api_opengl != 'no' and not gl_dep.found()
   if host_system == 'darwin'
     gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
   else
@@ -336,20 +343,24 @@ if need_api_opengl != 'no' or need_platform_glx != 'no'
       gl_includes += [compat_includes]
     endif
   endif
+endif
 
-  if host_system == 'darwin'
-    glx_dep = cc.find_library('GL', required : false)
-  else
-    glx_dep = gl_dep
-  endif
-
-  if need_api_opengl == 'no'
-    gl_dep = unneeded_dep
-  endif
-  if need_platform_glx == 'no'
-    glx_dep = unneeded_dep
+if need_platform_glx != 'no'
+  # (GLVND) GLX library and headers.
+  glx_dep = dependency('glx', method: 'pkg-config', required : false)
+
+  if not glx_dep.found()
+    if host_system == 'darwin'
+      glx_dep = cc.find_library('GL', required : false)
+    elif gl_dep.found()
+      glx_dep = gl_dep
+    elif need_platform_glx == 'yes'
+      error ('Could not find requested GLX library')
+    endif
   endif
+endif
 
+if need_api_opengl != 'no'
   opengl_includes = ''
   if host_system == 'darwin'
     opengl_includes += '''