From 27d5ade13c18574a4b53348e389e0a66fbc4c72f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Dec 2023 10:41:33 +0100 Subject: [PATCH] meson.build: generate version.h in include/mpd/ This fixes a "version.h" conflict when used as a Meson subproject: when the parent project also generates a "version.h", it is not clear which one will be included. We solve this by requiring the "mpd/" prefix for libmpdclient. See https://github.com/MusicPlayerDaemon/MPD/pull/1927 --- NEWS | 1 + include/mpd/client.h | 5 ++++- include/mpd/meson.build | 10 ++++++++++ meson.build | 12 ------------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index e32578f..c2655ff 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ libmpdclient 2.22 (not yet released) * drop the unmaintained Vala bindings +* fix "version.h" conflicts when used as a Meson subproject libmpdclient 2.21 (2023/12/20) * meson.build: allow using as a Meson subproject diff --git a/include/mpd/client.h b/include/mpd/client.h index f14cecc..07744e2 100644 --- a/include/mpd/client.h +++ b/include/mpd/client.h @@ -81,7 +81,10 @@ #include "stats.h" #include "status.h" #include "sticker.h" -#include "version.h" + +/* this is a generated header and may be installed in a different + filesystem tree, therefore we can't use just "version.h" */ +#include // IWYU pragma: end_exports diff --git a/include/mpd/meson.build b/include/mpd/meson.build index 2f7ece5..cce2359 100644 --- a/include/mpd/meson.build +++ b/include/mpd/meson.build @@ -1,3 +1,13 @@ +version_conf = configuration_data() +version_conf.set('MAJOR_VERSION', splitted_version[0]) +version_conf.set('MINOR_VERSION', splitted_version[1]) +if splitted_version.length() >= 3 + version_conf.set('PATCH_VERSION', splitted_version[2]) +else + version_conf.set('PATCH_VERSION', '0') +endif +version_h = configure_file(input: 'version.h.in', output: 'version.h', configuration: version_conf) + install_headers( 'async.h', 'audio_format.h', diff --git a/meson.build b/meson.build index 0fb6efb..4ba9113 100644 --- a/meson.build +++ b/meson.build @@ -35,16 +35,7 @@ endif configure_file(output: 'config.h', configuration: conf) -version_conf = configuration_data() splitted_version = meson.project_version().split('.') -version_conf.set('MAJOR_VERSION', splitted_version[0]) -version_conf.set('MINOR_VERSION', splitted_version[1]) -if splitted_version.length() >= 3 - version_conf.set('PATCH_VERSION', splitted_version[2]) -else - version_conf.set('PATCH_VERSION', '0') -endif -version_h = configure_file(input: 'include/mpd/version.h.in', output: 'version.h', configuration: version_conf) common_cflags = [ ] @@ -99,9 +90,6 @@ inc = include_directories( public_inc = include_directories( 'include', - - # for the generated version.h - '.', ) subdir('include/mpd')