This pattern works to get the absolute path of the header:
Yocto
EXTRA_OEMESON += "--prefix ${STAGING_DIR_TARGET}/usr"
Meson
vulkan_dep = dependency('vulkan')
vulkan_hpp = join_paths([
vulkan_dep.get_pkgconfig_variable('includedir', define_variable: ['prefix', get_option('prefix')]),
'vulkan',
'vulkan.hpp'
])
Implementation in build/meson-log.txt
Called `/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/rpi4/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot-native/usr/bin/pkg-config --define-variable=prefix=/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/rpi4/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot/usr --variable=includedir vulkan` -> 0
One would expect the following meson to work if STAGING_DIR_TARGET were set, as that's how pkg-config works:
vulkan_dep = dependency('vulkan')
vulkan_hpp = join_paths([
vulkan_dep.get_pkgconfig_variable('includedir'),
'vulkan',
'vulkan.hpp'
])
This will always return /usr/include/vulkan/vulkan.hpp regardless of PKG_CONFIG_SYSROOT_DIR value. With PKG_CONFIG_SYSROOT_DIR set, it should be /usr/include/vulkan/vulkan.hpp with prepend of PKG_CONFIG_SYSROOT_DIR value.
Sandbox testing of pkg-config
$ export STAGING_DIR_TARGET=/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/raspberrypi4-64/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot
$ PKG_CONFIG_SYSROOT_DIR=$STAGING_DIR_TARGET pkg-config --define-variable=prefix=/opt --variable=includedir vulkan
/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/raspberrypi4-64/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot/opt/include
meson.cross
Setting sys_root in the properties section of meson.cross (patching meson.bbclass) indirectly sets PKG_CONFIG_SYSROOT_DIR. The setting of sys_root is present in nativesdk_meson*.bb, not meson*.bb.
The issue for meson is that they are not passing the PKG_CONFIG_SYSROOT_DIR variable to the shell that launches pkg-config.
Joel