-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathmeson.build
106 lines (88 loc) · 2.22 KB
/
meson.build
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
project(
'libusbgx',
[ 'c', 'cpp' ],
version: '0.3.0',
license: 'LGPL2.1',
default_options: [
'warning_level=1',
'werror=true',
]
)
add_project_arguments([ '-D_GNU_SOURCE' ], language: 'c')
cc = meson.get_compiler('c')
config = configuration_data()
version = meson.project_version()
version_hex = run_command('sh', '-c', 'printf "0x%02x%02x%04x" $(printf "%s" "@0@" | sed -e "s/\./ /g")'.format(version), check: true).stdout().strip()
config.set('USBG_VERSION_HEX', version_hex)
dependencies = []
sources = []
c_flags = []
libconfig = dependency('libconfig', required: get_option('gadget-schemes'))
libdl = cc.find_library('dl', required: get_option('tests'))
cmocka = dependency('cmocka', required: get_option('tests'))
doxygen = find_program('doxygen', required: get_option('doxygen'))
if libconfig.found()
c_flags = ['-DHAS_GADGET_SCHEMES']
dependencies += libconfig
endif
inc = include_directories('include', '.')
subdir('src')
configure_file(
input: 'include/usbg/usbg_version.h.in',
output: 'usbg_version.h',
configuration: config
)
meson.add_install_script('install-headers.sh')
libusbgx = library(
'usbgx',
sources,
version: '2.0.0',
dependencies: dependencies,
include_directories: inc,
c_args: c_flags,
install: true,
)
# For subproject:
libusbgx_dep = declare_dependency(
include_directories: inc,
link_with: libusbgx,
)
if get_option('examples')
subdir('examples')
endif
if cmocka.found()
subdir('tests')
endif
if doxygen.found()
cfg = configuration_data()
if cmocka.found()
cfg.set('BUILD_TESTS_TRUE', '')
else
cfg.set('BUILD_TESTS_TRUE', 'X')
endif
configure_file(
input: 'doxygen.cfg.in',
output: 'doxygen.cfg',
configuration: cfg
)
env = environment()
env.set('PROJECT', meson.project_name())
env.set('VERSION', version)
env.set('DOCDIR', meson.current_build_dir() + '/doc')
env.set('SRCDIR', meson.current_source_dir())
run_command(doxygen,
meson.current_build_dir() + '/doxygen.cfg',
env: env,
check: true,
)
endif
pkgconfig = import('pkgconfig')
pkgconfig.generate(
libraries: libusbgx,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'USB gadget-configfs library',
)
# TODO: install doxygen?
# TODO: install cmake files