diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2022-04-21 16:48:16 +0100 |
---|---|---|
committer | John Levon <levon@movementarian.org> | 2022-05-09 23:28:10 +0100 |
commit | 5b69b60c197695579fd48abaa81c39b9984f1cab (patch) | |
tree | cd4717b8a875b2810af93d72e21b34248c62e761 /meson.build | |
parent | 18fb66bcec7b88301f949e586dbd773b8e3ee067 (diff) | |
download | libvfio-user-5b69b60c197695579fd48abaa81c39b9984f1cab.zip libvfio-user-5b69b60c197695579fd48abaa81c39b9984f1cab.tar.gz libvfio-user-5b69b60c197695579fd48abaa81c39b9984f1cab.tar.bz2 |
build: introduce Meson build file rules
The Meson build system used by many other virt projects (QEMU, libvirt
and others) is easier to understand & maintain rules for than cmake,
guiding towards best practice.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..726d185 --- /dev/null +++ b/meson.build @@ -0,0 +1,67 @@ +project( + 'libvfio-user', + 'c', + version: '0.0.1', + license: 'BSD-3-Clause', + meson_version: '>= 0.53.0', + default_options: [ + 'buildtype=debugoptimized', + 'c_std=gnu99', + 'warning_level=2', + ], +) + +opt_rpath = get_option('rpath') +opt_tran_pipe = get_option('tran-pipe') +opt_debug_logs = get_option('debug-logs') +opt_sanitizers = get_option('b_sanitize') +opt_debug = get_option('debug') + +cc = meson.get_compiler('c') + +prefix = get_option('prefix') +libdir = prefix / get_option('libdir') + +if prefix == '/usr' and not opt_rpath.enabled() + rpathdir = '' +else + rpathdir = libdir +endif + +thread_dep = dependency('threads') +dl_dep = cc.find_library('dl', required: true) + +json_c_version = '0.11' +json_c_dep = dependency('json-c', version: '>=' + json_c_version) + +cmocka_version = '' +cmocka_dep = dependency('cmocka', version: '>=' + cmocka_version) + + +pytest = find_program('pytest-3', required: false) +flake8 = find_program('flake8', required: false) +rstlint = find_program('restructuredtext-lint', required: false) +valgrind = find_program('valgrind', required: false) + +common_cflags = [ + '-D_GNU_SOURCE', +] + +if opt_debug_logs.enabled() or (not opt_debug_logs.disabled() and opt_debug) + common_cflags += ['-DDEBUG'] +endif + +if get_option('warning_level') == '2' + # -Wall is set for 'warning_level>=1' + # -Wextra is set for 'warning_level>=2' + common_cflags += cc.get_supported_arguments([ + '-Wno-missing-field-initializers', + '-Wmissing-declarations', + ]) +endif + +subdir('include') +subdir('lib') +subdir('samples') +subdir('test') +subdir('docs') |