Skip to content

Commit

Permalink
meson.build: generate version.h in include/mpd/
Browse files Browse the repository at this point in the history
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 MusicPlayerDaemon/MPD#1927
  • Loading branch information
MaxKellermann committed Dec 22, 2023
1 parent b050d50 commit 27d5ade
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion include/mpd/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mpd/version.h>

// IWYU pragma: end_exports

Expand Down
10 changes: 10 additions & 0 deletions include/mpd/meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
12 changes: 0 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
]
Expand Down Expand Up @@ -99,9 +90,6 @@ inc = include_directories(

public_inc = include_directories(
'include',

# for the generated version.h
'.',
)

subdir('include/mpd')
Expand Down

0 comments on commit 27d5ade

Please sign in to comment.