[gtk+] build: Use pkg-config to find Vulkan



commit 3b0e6720af4b92d900f0ee2dd8937b360ffbf052
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Feb 5 11:42:02 2018 +0000

    build: Use pkg-config to find Vulkan
    
    The standard Vulkan SDK ships with a pkg-config file, like a modern
    library should.
    
    We should fall back to finding the library and header only for platforms
    where pkg-config is not really a thing.
    
    Based on a patch by: Daniel Stone <daniels collabora com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793181

 gdk/meson.build |    2 +-
 meson.build     |   40 ++++++++++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/gdk/meson.build b/gdk/meson.build
index e722ee6..267f53f 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -165,7 +165,7 @@ gdk_deps = [
   fontconfig_dep,
   platform_gio_dep,
   pangocairo_dep,
-  vulkan_lib
+  vulkan_dep,
 ]
 
 # add generated gdk sources
diff --git a/meson.build b/meson.build
index 1b46d3e..d7e7a72 100644
--- a/meson.build
+++ b/meson.build
@@ -550,27 +550,35 @@ endif
 # Check for Vulkan support
 # TODO: move to gsk subfolder maybe? Or will it be used elsewhere too?
 have_vulkan = false
-vulkan_lib = []
-
-if cc.get_id() == 'msvc'
-  vulkan_libname = 'vulkan-1'
-else
-  vulkan_libname = 'vulkan'
-endif
+vulkan_pkg_found = false
+vulkan_dep = []
 
 enable_vulkan = get_option('enable-vulkan')
-if enable_vulkan != 'no'
-  vulkan_lib = cc.find_library(vulkan_libname, required: false)
-  if vulkan_lib.found() and cc.has_function('vkCreateInstance', dependencies: vulkan_lib) and 
cc.has_header('vulkan/vulkan.h')
+if enable_vulkan == 'no'
+  message('Vulkan support explicitly disabled')
+else
+  vulkan_dep = dependency('vulkan', required: false)
+  if vulkan_dep.found()
     have_vulkan = true
-    pc_gdk_extra_libs += ['-l@0@'.format(vulkan_libname)]
-  elif enable_vulkan == 'yes'
+    vulkan_pkg_found = true
+  else
+    if cc.get_id() == 'msvc'
+      vulkan_libname = 'vulkan-1'
+    else
+      vulkan_libname = 'vulkan'
+    endif
+    vulkan_dep = cc.find_library(vulkan_libname, required: false)
+    if vulkan_lib.found() and cc.has_function('vkCreateInstance', dependencies: vulkan_lib) and 
cc.has_header('vulkan/vulkan.h')
+      have_vulkan = true
+      pc_gdk_extra_libs += ['-l@0@'.format(vulkan_libname)]
+    endif
+  endif
+  if enable_vulkan == 'yes' and not have_vulkan
     error('Vulkan support not found, but was explicitly requested.')
   endif
-else
-  message('Vulkan support explicitly disabled')
 endif
 
+
 if cloudproviders_enabled
   cloudproviders_dep = dependency('cloudproviders', required: true)
   if cloudproviders_dep.found()
@@ -624,6 +632,10 @@ if cairogobj_pkg_found
   gdk_packages += ' '.join([ ' cairo-gobject', cairo_req ])
 endif
 
+if vulkan_pkg_found
+  gdk_packages += 'vulkan'
+endif
+
 pkgconf.set('GDK_PACKAGES', gdk_packages)
 pkgconf.set('GSK_PACKAGES',
             ' '.join([ 'graphene-gobject-1.0', graphene_req ]))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]