From 18edd4eb50fb1036419f68a9cb55ef7767f668c6 Mon Sep 17 00:00:00 2001 From: Danilo Spinella Date: Thu, 13 Feb 2020 19:16:31 +0100 Subject: [PATCH] meson: Add option to use system vulkan headers --- meson.build | 19 +++++++++++++++++-- meson_options.txt | 1 + src/meson.build | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index adb9dae0..f20b3e2e 100644 --- a/meson.build +++ b/meson.build @@ -108,9 +108,15 @@ endif inc_common = [ include_directories('include'), - include_directories('modules/Vulkan-Headers/include'), ] +dep_vulkan = dependency('vulkan', required: get_option('use_system_vulkan')) +if not dep_vulkan.found() + inc_common += [ + include_directories('modules/Vulkan-Headers/include') + ] +endif + # Check for generic C arguments c_args = [] foreach a : ['-Werror=implicit-function-declaration', @@ -184,7 +190,16 @@ endif dep_pthread = cc.find_library('pthread') -vk_api_xml = files('modules/Vulkan-Headers/registry/vk.xml') +if dep_vulkan.found() + datadir = get_option('datadir') + if not datadir.startswith('/') + datadir = get_option('prefix') / datadir + endif + vk_api_xml = files(datadir / 'vulkan/registry/vk.xml') +else + vk_api_xml = files('modules/Vulkan-Headers/registry/vk.xml') +endif + vk_layer_table_helpers = [] vk_enum_to_str = custom_target( diff --git a/meson_options.txt b/meson_options.txt index cf87a716..9d1d8279 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('glibcxx_asserts', type : 'boolean', value : false) +option('use_system_vulkan', type : 'feature', value : 'disabled', description: 'Use system vulkan headers instead of the provided ones') diff --git a/src/meson.build b/src/meson.build index 196b810b..3095632d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -66,7 +66,8 @@ vklayer_mesa_overlay = shared_library( vulkan_wsi_deps, libimgui_core_dep, dep_dl, - dep_pthread], + dep_pthread, + dep_vulkan], include_directories : inc_common, link_args : cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro']), install : true