-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmeson.build
More file actions
186 lines (155 loc) · 5.45 KB
/
meson.build
File metadata and controls
186 lines (155 loc) · 5.45 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
project('dbzero', 'cpp', default_options :['buildtype=release', 'b_ndebug=if-release'])
cc = meson.get_compiler('cpp')
compiler_id = cc.get_id()
message('Compiler ID: ' + compiler_id)
message('Build system: ' + build_machine.system())
if build_machine.system() == 'linux' or build_machine.system() == 'darwin'
# Common flags for both GCC and Clang on Linux/Darwin
common_args = [
'-Wno-unused-result',
'-Wno-unused-local-typedefs',
'-Wno-deprecated-declarations',
'-Werror=switch',
'-Werror=return-type',
'-fPIC',
'-fno-omit-frame-pointer',
'-ldl',
'-lm',
'-lpthread',
]
add_project_arguments(common_args, language : 'cpp')
# GCC-specific options
if compiler_id == 'gcc'
message('Using GCC-specific options')
gcc_args = [
'-no-pie',
'-ftemplate-backtrace-limit=0',
'-fuse-ld=gold',
]
add_project_arguments(gcc_args, language : 'cpp')
endif
# Clang-specific options
if compiler_id == 'clang'
message('Using Clang-specific options')
clang_args = [
'-ftemplate-backtrace-limit=0',
# REMOVE BEFORE COMMIT,
'-Wno-inconsistent-missing-override',
'-Wno-unused-private-field',
'-Wno-mismatched-tags',
'-Wno-overloaded-virtual',
'-Wno-class-memaccess'
]
add_project_arguments(clang_args, language : 'cpp')
# Clang on Linux might support gold linker
if build_machine.system() == 'linux'
add_project_arguments('-fuse-ld=lld', language : 'cpp')
endif
endif
# Darwin-specific adjustments
if build_machine.system() == 'darwin'
message('Using Darwin-specific options')
# Remove -Wno-address-of-packed-member as it might not be available on all Darwin compilers
else
# Linux-specific: add address-of-packed-member warning suppression
add_project_arguments('-Wno-address-of-packed-member', language : 'cpp')
endif
add_project_arguments('-std=c++17', language : 'cpp')
else
add_project_arguments(
'-ldl',
'-lm',
'-lpthread',
language : 'cpp')
add_project_arguments('-std:c++20', language : 'cpp')
endif
enable_debug_exceptions = get_option('enable_debug_exceptions')
message('Enable debug exceptions: ' + enable_debug_exceptions.to_string())
if enable_debug_exceptions
message('Enabling debug exceptions')
add_project_arguments('-DENABLE_DEBUG_EXCEPTIONS=1', language: 'c')
else
message('Disabling debug exceptions')
add_project_arguments('-DENABLE_DEBUG_EXCEPTIONS=0', language: 'c')
endif
enable_sanitizers = get_option('enable_sanitizers')
if enable_sanitizers
message('Enabling address and undefined behavior sanitizers')
add_project_arguments('-fsanitize=address', language: 'cpp')
add_project_link_arguments('-fsanitize=address', language: 'cpp')
else
message('Disabling address and undefined behavior sanitizers')
endif
buildtype = get_option('buildtype')
build_suffix = ''
if buildtype.startswith('release')
add_project_arguments('-O2', language : 'cpp')
elif buildtype.startswith('debug')
build_suffix='D'
endif
dbzero_deps = []
include_dirs = include_directories(['src/'])
include_dirs_test = include_directories(['src/','tests/'])
py3_inst = import('python').find_installation('python3', pure: false)
install_dir = py3_inst.get_install_dir() / 'dbzero' / 'libs'
deps = []
python_deps = py3_inst.dependency()
deps += python_deps
all_srcs = []
subdir('src/dbzero')
subdir('dbzero')
link_with = []
foreach dep : dbzero_deps
link_with += dep
endforeach
link_tests_with = link_with
tests_sources = []
dbzero_lib = static_library('pyzero', [all_srcs], include_directories:include_dirs, dependencies: [deps], install : true, install_dir: install_dir)
all_deps = [deps]
build_tests = get_option('build_tests')
if build_tests
if build_machine.system() == 'linux'
python_embed_dep = dependency('python3-embed', main:true, required: true)
endif
if build_machine.system() == 'linux'
deps += python_embed_dep
endif
gtest_proj = subproject('gtest')
gtest_dep = gtest_proj.get_variable('gtest_dep')
gmock_dep = gtest_proj.get_variable('gmock_dep')
gtest_dep = gtest_proj.get_variable('gtest_dep')
gtest_dep = dependency('gtest', main : true, required : false)
gmock_dep = dependency('gmock', main : true, required : false)
all_deps += gtest_dep
all_deps += gmock_dep
message('Building C++ tests')
subdir('tests')
e = executable('tests' + build_suffix + '.x', [all_srcs,tests_sources], dependencies: [deps, gtest_dep, gmock_dep],
link_with: [dbzero_lib, link_with], include_directories:include_dirs_test, link_language : 'cpp',)
test('gtest tests', e)
else
message('Skipping C++ tests build')
endif
py3avlw = py3_inst.extension_module('dbzero',
sources: ['src/dbzero/bindings/python/dbzero.cpp'],
dependencies : all_deps,
include_directories:include_dirs,
link_with:[dbzero_lib, link_with],
link_language : 'cpp',
override_options: [
'cpp_rtti=true',
],
install: true,
subdir: 'dbzero',
)
# License and notice files
license_files = [
'./LICENSE',
'./NOTICE',
'./THIRD_PARTY_LICENSES/GOOGLETEST_LICENSE',
'./THIRD_PARTY_LICENSES/BOOST_LICENSE_1_0',
]
py3_inst.install_sources(
license_files,
subdir: 'dbzero'
)