forked from mavlink-router/mavlink-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
157 lines (140 loc) · 6.03 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
project(
'mavlink-router',
'cpp', 'c',
version: '3',
license: 'Apache 2.0',
default_options: [
'cpp_std=gnu++11',
'prefix=/usr',
'warning_level=2',
'buildtype=debugoptimized',
],
meson_version : '>= 0.55',
)
project_source_root = meson.current_source_dir()
conf = configuration_data()
conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
conf.set_quoted('VERSION', meson.project_version(), description : 'Project version')
conf.set_quoted('PACKAGE', meson.project_name())
cxx = meson.get_compiler('cpp')
cc = meson.get_compiler('c')
# Mandatory dependencies
dep_math = cxx.find_library('m')
dep_rt = cxx.find_library('rt')
dep_thread = dependency('threads')
# Optional dependencies
systemd_system_unit_dir = get_option('systemdsystemunitdir')
if systemd_system_unit_dir == 'auto'
dep_systemd = dependency('systemd')
systemd_system_unit_dir = dep_systemd.get_variable(pkgconfig: 'systemdsystemunitdir')
endif
dep_gtest = dependency('gtest', main : true, required : false)
# Additional warnings
possible_cc_flags = [
'-Wno-inline',
'-Wundef',
'-Wformat=2',
'-Wlogical-op',
'-Wsign-compare',
'-Wformat-security',
'-Wmissing-include-dirs',
'-Wformat-nonliteral',
'-Wold-style-definition',
'-Wpointer-arith',
'-Winit-self',
'-Wdeclaration-after-statement',
'-Wfloat-equal',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wredundant-decls',
'-Wmissing-declarations',
'-Wmissing-noreturn',
'-Wshadow',
'-Wendif-labels',
'-Wstrict-aliasing=3',
'-Wwrite-strings',
'-Wno-long-long',
'-Wno-overlength-strings',
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wnested-externs',
'-Wchar-subscripts',
'-Wtype-limits',
'-Wuninitialized',
]
possible_cxx_flags = [
'-Waddress-of-packed-member',
'-Wno-inline',
'-Wundef',
'-Wformat=2',
'-Wlogical-op',
'-Wsign-compare',
'-Wformat-security',
'-Wmissing-include-dirs',
'-Wformat-nonliteral',
'-Wpointer-arith',
'-Winit-self',
'-Wfloat-equal',
'-Wredundant-decls',
'-Wmissing-declarations',
'-Wmissing-noreturn',
'-Wshadow',
'-Wendif-labels',
'-Wstrict-aliasing=3',
'-Wwrite-strings',
'-Wno-long-long',
'-Wno-overlength-strings',
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wchar-subscripts',
'-Wtype-limits',
'-Wuninitialized',
]
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
add_project_arguments(cc.get_supported_arguments(possible_cxx_flags), language : 'cpp')
# System or compiler dependent tweaks
has_waddress_of_packed_member = cxx.has_argument('-Waddress-of-packed-member')
conf.set10('HAVE_WADDRESS_OF_PACKED_MEMBER', has_waddress_of_packed_member)
has_aio_init_symbols = cxx.has_header_symbol('aio.h', 'aio_init')
conf.set10('HAVE_DECL_AIO_INIT', has_aio_init_symbols)
# Always include config.h
config_h = configure_file(output : 'config.h', configuration : conf)
add_project_arguments('-include', 'config.h', language : 'cpp')
add_project_arguments('-include', 'config.h', language : 'c')
# Git version tag
vcs_tagger = [project_source_root + '/tools/meson-vcs-tag.sh',
project_source_root]
version_h = vcs_tag(input : 'src/version.h.in',
output: 'git_version.h',
command: vcs_tagger)
# Includes
mavlink_inc = include_directories('modules/mavlink_c_library_v2/ardupilotmega')
src_inc = include_directories('src')
# Additonal data to be installed
configure_file(
input: 'mavlink-router.service.in',
output: 'mavlink-router.service',
configuration: conf,
install_dir: systemd_system_unit_dir,
)
subdir('src')
subdir('examples')
# Use clang-tidy to modernize code and check for common code style issues
clangtidy = find_program('run-clang-tidy', required: false)
clangtidy_wrapper = files('tools/meson-clang-tidy.sh')
if clangtidy.found()
# common set of auto-fixable issues
run_target('clangtidy-autofix',
command : [clangtidy_wrapper, '-p', meson.current_build_dir(),
'-header-filter', '@SOURCE_ROOT@/src/.*',
'-fix', '-format',
])
# check, which need manual evaluation on a case by case basis
run_target('clangtidy-check',
command : [clangtidy_wrapper, '-p', meson.current_build_dir(),
'-header-filter', '@SOURCE_ROOT@/src/.*',
'-checks=bugprone-*,-bugprone-easily-swappable-parameters,cppcoreguidelines-*,-cppcoreguidelines-avoid-goto,-cppcoreguidelines-macro-usage,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,misc-*,-misc-misleading-identifier,-misc-no-recursion,modernize-concat-nested-namespaces,modernize-replace-auto-ptr,modernize-replace-disallow-copy-and-assign-macro,modernize-replace-random-shuffle,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,performance-*,readability-avoid-const-params-in-decls,readability-container-size-empty,readability-convert-member-functions-to-static,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-non-const-parameter,readability-redundant-access-specifiers,readability-redundant-control-flow,readability-redundant-preprocessor,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-suspicious-call-argument,readability-uppercase-literal-suffix',
])
endif