-
Notifications
You must be signed in to change notification settings - Fork 5
/
meson.build
78 lines (68 loc) · 2.23 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
project('OTAESGCM', 'cpp',
default_options : [
'c_std=c11', 'cpp_std=c++11']
)
cpp_args = [
'-O0',
'-Wall', '-Wextra', '-Werror',
'-Wno-non-virtual-dtor',
'-DEXT_AVAILABLE_ARDUINO_LIB_OTAESGCM'
]
cpp_args_clang_compat = ['-fstack-check', '-fstack-protector-strong']
compiler = meson.get_compiler('cpp')
if (compiler.get_id() == 'gcc') # and (compiler.version().version_compare('<8'))
cpp_args += cpp_args_clang_compat
else
warning('Skipping -fstack-check and -fstack-protector-strong due to old compiler version.')
endif
# Setup and compile gtest.
# Tries to find gtest via normal dependency manager (e.g. pkgconf) and falls
# back to downloading and compiling using a wrap file.
gtest_dep = dependency('gtest_main', required : false)
if not gtest_dep.found()
thread_dep = dependency('threads')
gtest_proj = subproject('gtest')
gtest_inc = gtest_proj.get_variable('gtest_incdir')
gtest_src = [
gtest_proj.get_variable('gtest_libsources'),
gtest_proj.get_variable('gtest_mainsources')
]
gtest_lib = static_library('gtest', gtest_src,
include_directories : gtest_inc,
dependencies : thread_dep) # + all your args here
gtest_dep = declare_dependency(
include_directories : gtest_inc,
link_with : gtest_lib)
endif
# Compile OTAESGCM library for other tests.
inc = include_directories(
'content/OTAESGCM',
'content/OTAESGCM/utility',
'portableUnitTests'
)
src = [
'content/OTAESGCM/utility/OTAESGCM_OTAES128AVR.cpp',
'content/OTAESGCM/utility/OTAESGCM_OTAESGCM.cpp',
]
if meson.is_subproject()
libOTAESGCM = static_library('OTAESGCM', src,
include_directories : inc,
cpp_args : cpp_args,
install : true
)
libOTAESGCM_dep = declare_dependency(
include_directories : inc,
link_with : libOTAESGCM
)
else
# Compile test executable.
# This is broken out to avoid compile errors due to lack of gtest.
test_src = 'portableUnitTests/main.cpp'
test_app = executable('OTAESGCMTests', [src, test_src],
include_directories : inc,
dependencies : gtest_dep,
cpp_args : cpp_args,
install : false
)
test('unit_tests', test_app)
endif