aboutsummaryrefslogtreecommitdiff
path: root/meson.build
blob: b54dede11c57c250cb5812f4a9eb488e47fc9f2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
project(
    'libvfio-user',
    'c',
    version: '0.0.1',
    license: 'BSD-3-Clause',
    meson_version: '>= 0.53.0',
    default_options: [
        'buildtype=debug',
        'c_std=gnu99',
        'warning_level=2',
        # clang with dwarf-5 can break valgrind
        'c_args=-gdwarf-4',
    ],
)

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')
opt_shadow_ioeventfd = get_option('shadow-ioeventfd')
opt_debug_sgl = get_option('debug-sgl')

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)
misspell_fixer = find_program('misspell-fixer', required: false)
rstlint = find_program('restructuredtext-lint', required: false)
valgrind = find_program('valgrind', required: false)

common_cflags = [
    '-D_GNU_SOURCE',
]

if opt_debug
    common_cflags += '-Werror'
endif

if opt_debug_logs.enabled() or (not opt_debug_logs.disabled() and opt_debug)
    common_cflags += ['-DDEBUG']
endif

if opt_shadow_ioeventfd
    common_cflags += ['-DSHADOW_IOEVENTFD']
endif

if opt_debug_sgl
    common_cflags += ['-DDEBUG_SGL']
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',
        '-Wwrite-strings',
    ])
endif

subdir('include')
subdir('lib')
subdir('samples')
subdir('test')
subdir('docs')