-
Notifications
You must be signed in to change notification settings - Fork 521
/
Copy pathmeson.build
226 lines (202 loc) · 6.24 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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
project(
'SQLiteCpp', 'cpp',
# SQLiteCpp requires C++11 support
default_options: ['cpp_std=c++11'],
license: 'MIT',
version: '3.1.1',
)
cxx = meson.get_compiler('cpp')
## at best we might try to test if this code compiles
## testing for compilers or platforms is not reliable enough
## example: native clang on windows or mingw in windows
unix_like_code = '''
#if defined(unix) || defined(__unix__) || defined(__unix)
// do nothing
#else
# error "Non Unix-like OS"
#endif
'''
unix_like = cxx.compiles(unix_like_code, name : 'unix like environment')
thread_dep = dependency('threads')
# sqlite3 support
sqlite3_dep = dependency(
'sqlite3',
fallback: ['sqlite3', 'sqlite3_dep']
)
sqlitecpp_incl = [
include_directories('include')
]
sqlitecpp_srcs = [
'src/Backup.cpp',
'src/Column.cpp',
'src/Database.cpp',
'src/Exception.cpp',
'src/Statement.cpp',
'src/Transaction.cpp',
]
sqlitecpp_args = [
'-Wall',
]
sqlitecpp_link = []
sqlitecpp_deps = [
sqlite3_dep,
thread_dep,
]
## used to override the default sqlitecpp options like cpp standard
sqlitecpp_opts = []
## tests
sqlitecpp_test_srcs = [
'tests/Column_test.cpp',
'tests/Database_test.cpp',
'tests/Statement_test.cpp',
'tests/Backup_test.cpp',
'tests/Transaction_test.cpp',
'tests/VariadicBind_test.cpp',
'tests/Exception_test.cpp',
'tests/ExecuteMany_test.cpp',
]
sqlitecpp_test_args = [
# do not use ambiguous overloads by default
'-DNON_AMBIGOUS_OVERLOAD'
]
## samples
sqlitecpp_sample_srcs = [
'examples/example1/main.cpp',
]
# if not using MSVC we need to add this compiler arguments
# for a list of MSVC supported arguments please check:
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically?view=msvc-170
if not (host_machine.system() == 'windows' and cxx.get_id() == 'msvc')
sqlitecpp_args += [
'-Wextra',
'-Wpedantic',
'-Wswitch-enum',
'-Wshadow',
'-Wno-long-long',
]
endif
## using MSVC headers requires c++14, if not will show an error on xstddef as:
## 'auto' return without trailing return type; deduced return types are a C++14 extension
if host_machine.system() == 'windows'
message('[WINDOWS] using c++14 standard')
sqlitecpp_opts += [
'cpp_std=c++14',
]
endif
# Options relative to SQLite and SQLiteC++ functions
if get_option('SQLITE_ENABLE_COLUMN_METADATA')
sqlitecpp_args += [
'-DSQLITE_ENABLE_COLUMN_METADATA',
]
endif
if get_option('SQLITE_ENABLE_ASSERT_HANDLER')
sqlitecpp_args += [
'-DSQLITE_ENABLE_ASSERT_HANDLER',
]
endif
if get_option('SQLITE_HAS_CODEC')
sqlitecpp_args += [
'SQLITE_HAS_CODEC',
]
endif
if get_option('SQLITE_USE_LEGACY_STRUCT')
sqlitecpp_args += [
'-DSQLITE_USE_LEGACY_STRUCT',
]
endif
if unix_like
sqlitecpp_args += [
'-DfPIC',
]
# add dl dependency
libdl_dep = cxx.find_library('dl')
sqlitecpp_deps += [
libdl_dep,
]
endif
if get_option('b_coverage')
# Prevent the compiler from removing the unused inline functions so that they get tracked as "non-covered"
sqlitecpp_args += [
'-fkeep-inline-functions',
'-fkeep-static-functions',
]
endif
libsqlitecpp = library(
'sqlitecpp',
sqlitecpp_srcs,
include_directories: sqlitecpp_incl,
cpp_args: sqlitecpp_args,
dependencies: sqlitecpp_deps,
# override the default options
override_options: sqlitecpp_opts,
# install: true,
# API version for SQLiteCpp shared library.
version: '0',)
if get_option('SQLITECPP_BUILD_TESTS')
# for the unit tests we need to link against a static version of SQLiteCpp
libsqlitecpp_static = static_library(
'sqlitecpp_static',
sqlitecpp_srcs,
include_directories: sqlitecpp_incl,
cpp_args: sqlitecpp_args,
dependencies: sqlitecpp_deps,
# override the default options
override_options: sqlitecpp_opts,)
# static libraries do not have a version
endif
install_headers(
'include/SQLiteCpp/SQLiteCpp.h',
'include/SQLiteCpp/Assertion.h',
'include/SQLiteCpp/Backup.h',
'include/SQLiteCpp/Column.h',
'include/SQLiteCpp/Database.h',
'include/SQLiteCpp/Exception.h',
'include/SQLiteCpp/Statement.h',
'include/SQLiteCpp/Transaction.h',
'include/SQLiteCpp/VariadicBind.h',
'include/SQLiteCpp/ExecuteMany.h',
)
sqlitecpp_dep = declare_dependency(
include_directories: sqlitecpp_incl,
link_with: libsqlitecpp,
)
if get_option('SQLITECPP_BUILD_TESTS')
## make the dependency static so the unit tests can link against it
## (mainly for windows as the symbols are not exported by default)
sqlitecpp_static_dep = declare_dependency(
include_directories: sqlitecpp_incl,
link_with: libsqlitecpp_static,
)
endif
if get_option('SQLITECPP_BUILD_TESTS')
gtest_dep = dependency(
'gtest',
main : true,
fallback: ['gtest', 'gtest_dep'])
sqlitecpp_test_dependencies = [
gtest_dep,
sqlitecpp_static_dep,
sqlite3_dep,
]
testexe = executable('testexe', sqlitecpp_test_srcs,
dependencies: sqlitecpp_test_dependencies,
cpp_args: sqlitecpp_test_args,
# override the default options
override_options: sqlitecpp_opts,)
test_args = []
test('sqlitecpp unit tests', testexe, args: test_args)
endif
if get_option('SQLITECPP_BUILD_EXAMPLES')
## demo executable
sqlitecpp_demo_exe = executable('SQLITECPP_sample_demo',
sqlitecpp_sample_srcs,
dependencies: sqlitecpp_dep,
# override the default options
override_options: sqlitecpp_opts,)
endif
pkgconfig = import('pkgconfig')
pkgconfig.generate(
libsqlitecpp,
description: 'a smart and easy to use C++ SQLite3 wrapper.',
version: meson.project_version(),
)