meson.build: fix build with meson > 0.38.1
[libmpdclient.git] / meson.build
blob98047f3bdee1d889e586dd7d2a97935ebeda68b0
1 project('libmpdclient', 'c', version: '2.13',
2   default_options: [
3     'c_std=c99',
4   ],
5   license: 'BSD',
8 cc = meson.get_compiler('c')
10 conf = configuration_data()
11 conf.set_quoted('PACKAGE', meson.project_name())
12 conf.set_quoted('VERSION', meson.project_version())
14 if host_machine.system() != 'windows'
15   conf.set_quoted('DEFAULT_SOCKET', get_option('default_socket'))
16 endif
18 conf.set_quoted('DEFAULT_HOST', get_option('default_host'))
19 conf.set('DEFAULT_PORT', get_option('default_port'))
21 if get_option('tcp')
22   conf.set('ENABLE_TCP', '1')
24   if cc.has_function('getaddrinfo')
25     conf.set('HAVE_GETADDRINFO', '1')
26   endif
27 endif
29 configure_file(output: 'config.h', configuration: conf)
31 version_conf = configuration_data()
32 splitted_version = meson.project_version().split('.')
33 version_conf.set('MAJOR_VERSION', splitted_version[0])
34 version_conf.set('MINOR_VERSION', splitted_version[1])
35 if splitted_version.length() >= 3
36   version_conf.set('PATCH_VERSION', splitted_version[2])
37 else
38   version_conf.set('PATCH_VERSION', '0')
39 endif
40 configure_file(input: 'include/mpd/version.h.in', output: 'version.h', configuration: version_conf)
42 common_cflags = [
43   # for strdup() with glibc
44   '-D_GNU_SOURCE',
47 test_cflags = [
48   '-Wall',
49   '-Wextra',
50   '-Wno-deprecated-declarations',
51   '-Wmissing-prototypes',
52   '-Wshadow',
53   '-Wpointer-arith',
54   '-Wstrict-prototypes',
55   '-Wcast-qual',
56   '-Wwrite-strings',
59 foreach f: test_cflags
60   if cc.has_argument(f)
61     common_cflags += [ f ]
62   endif
63 endforeach
65 add_global_arguments(common_cflags, language: 'c')
67 common_ldflags = []
69 test_ldflags = [
72 if host_machine.system() == 'linux'
73   test_ldflags += [ '-Wl,--version-script=' + join_paths(meson.source_root(), 'libmpdclient.ld') ]
74 endif
76 foreach f: test_ldflags
77   if cc.has_argument(f)
78     common_ldflags += [ f ]
79   endif
80 endforeach
82 platform_deps = []
83 if host_machine.system() == 'windows'
84   platform_deps = [cc.find_library('ws2_32')]
85 endif
87 inc = include_directories(
88   'src',
89   'include',
91   # for the generated config.h
92   '.',
95 libmpdclient = library('mpdclient',
96   'src/async.c',
97   'src/ierror.c',
98   'src/resolver.c',
99   'src/capabilities.c',
100   'src/connection.c',
101   'src/database.c',
102   'src/directory.c',
103   'src/rdirectory.c',
104   'src/error.c',
105   'src/fd_util.c',
106   'src/output.c',
107   'src/coutput.c',
108   'src/entity.c',
109   'src/idle.c',
110   'src/iso8601.c',
111   'src/list.c',
112   'src/mixer.c',
113   'src/parser.c',
114   'src/password.c',
115   'src/player.c',
116   'src/playlist.c',
117   'src/player.c',
118   'src/rplaylist.c',
119   'src/cplaylist.c',
120   'src/queue.c',
121   'src/quote.c',
122   'src/recv.c',
123   'src/response.c',
124   'src/run.c',
125   'src/search.c',
126   'src/send.c',
127   'src/socket.c',
128   'src/song.c',
129   'src/status.c',
130   'src/cstatus.c',
131   'src/stats.c',
132   'src/cstats.c',
133   'src/sync.c',
134   'src/tag.c',
135   'src/sticker.c',
136   'src/settings.c',
137   'src/message.c',
138   'src/cmessage.c',
139   link_depends: [
140     'libmpdclient.ld'
141   ],
142   include_directories: inc,
143   dependencies: [
144     platform_deps,
145   ],
146   link_args: common_ldflags,
147   version: meson.project_version(),
148   soversion: splitted_version[0],
149   install: true
151 libmpdclient_dep = declare_dependency(link_with: libmpdclient)
153 executable('example',
154   'src/example.c',
155   include_directories: inc,
156   dependencies: [
157     libmpdclient_dep,
158   ])
160 install_headers(
161   'include/mpd/async.h',
162   'include/mpd/audio_format.h',
163   'include/mpd/client.h',
164   'include/mpd/capabilities.h',
165   'include/mpd/compiler.h',
166   'include/mpd/connection.h',
167   'include/mpd/database.h',
168   'include/mpd/directory.h',
169   'include/mpd/entity.h',
170   'include/mpd/error.h',
171   'include/mpd/idle.h',
172   'include/mpd/list.h',
173   'include/mpd/mixer.h',
174   'include/mpd/parser.h',
175   'include/mpd/password.h',
176   'include/mpd/player.h',
177   'include/mpd/playlist.h',
178   'include/mpd/protocol.h',
179   'include/mpd/queue.h',
180   'include/mpd/recv.h',
181   'include/mpd/response.h',
182   'include/mpd/send.h',
183   'include/mpd/status.h',
184   'include/mpd/stats.h',
185   'include/mpd/tag.h',
186   'include/mpd/output.h',
187   'include/mpd/pair.h',
188   'include/mpd/search.h',
189   'include/mpd/socket.h',
190   'include/mpd/song.h',
191   'include/mpd/sticker.h',
192   'include/mpd/settings.h',
193   'include/mpd/message.h',
194   join_paths(meson.build_root(), 'version.h'),
195   subdir: 'mpd')
197 docdir = join_paths(get_option('datadir'), 'doc', meson.project_name())
198 install_data('AUTHORS', 'COPYING', 'NEWS', 'README.rst',
199   install_dir: docdir)
201 install_data('vapi/libmpdclient.vapi',
202   install_dir : join_paths(get_option('datadir'), 'vala', 'vapi'))
204 pkg_mod = import('pkgconfig')
205 pkg_mod.generate(
206   libraries: libmpdclient,
207   version: meson.project_version(),
208   name: 'libmpdclient',
209   description: 'Music Player Daemon client library',
212 if get_option('documentation')
213   doxygen = find_program('doxygen', required: false)
214   if doxygen.found()
215     subdir('doc')
216   endif
217 endif
219 if get_option('test')
220   check_dep = dependency('check')
221   subdir('test')
222 endif