From b5cfc75b587d5df5af61642f70957f18e9ea9d34 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Nov 2021 18:35:54 -0800 Subject: [PATCH 1/2] meson: Add dependency for for libpkgconf This allows others using libpkgconf as a dependency to do use this as a subproject. They can write something like: ```meson dependency('libpkgconf', fallback : ['libpkgconf', 'dep_libpkgconf']) ``` Then install a wrap file for libpkgconf and build it as part of their project. --- meson.build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meson.build b/meson.build index 918d40b..248eaeb 100644 --- a/meson.build +++ b/meson.build @@ -72,6 +72,12 @@ libpkgconf = library('pkgconf', soversion : '3', ) +# For other projects using libpkgconfig as a subproject +dep_libpkgconf = declare_dependency( + link_with : libpkgconf, + include_directories : include_directories('.'), +) + pkg = import('pkgconfig') pkg.generate(libpkgconf, name : 'libpkgconf', -- 2.41.0 From f6b28e85d67ec99bad7b67713a95970429e5ada5 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Nov 2021 18:39:56 -0800 Subject: [PATCH 2/2] meson: make use of override_dependency() if possible This allows simplifying the subproject override to simply ```meson dependency('libpkgconf') ``` --- meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 248eaeb..5136b21 100644 --- a/meson.build +++ b/meson.build @@ -78,6 +78,12 @@ dep_libpkgconf = declare_dependency( include_directories : include_directories('.'), ) +# If we have a new enough meson override the dependency so that only +# `dependency('libpkgconf')` is required from the consumer +if meson.version().version_compare('>= 0.54.0') + meson.override_dependency('libpkgconf', dep_libpkgconf) +endif + pkg = import('pkgconfig') pkg.generate(libpkgconf, name : 'libpkgconf', @@ -113,4 +119,4 @@ install_man('man/pc.5') install_man('man/pkgconf-personality.5') install_data('pkg.m4', install_dir: 'share/aclocal') install_data('AUTHORS', install_dir: 'share/doc/pkgconf') -install_data('README.md', install_dir: 'share/doc/pkgconf') \ No newline at end of file +install_data('README.md', install_dir: 'share/doc/pkgconf') -- 2.41.0