@@ -46,6 +46,8 @@ sqlitecpp_deps = [
46
46
sqlite3_dep,
47
47
thread_dep,
48
48
]
49
+ ## used to override the default sqlitecpp options like cpp standard
50
+ sqlitecpp_opts = []
49
51
50
52
## tests
51
53
@@ -59,6 +61,10 @@ sqlitecpp_test_srcs = [
59
61
' tests/Exception_test.cpp' ,
60
62
' tests/ExecuteMany_test.cpp' ,
61
63
]
64
+ sqlitecpp_test_args = [
65
+ # do not use ambiguous overloads by default
66
+ ' -DNON_AMBIGOUS_OVERLOAD'
67
+ ]
62
68
63
69
## samples
64
70
@@ -78,7 +84,14 @@ if not (host_machine.system() == 'windows' and cxx.get_id() == 'msvc')
78
84
' -Wno-long-long' ,
79
85
]
80
86
endif
81
-
87
+ ## using MSVC headers requires c++14, if not will show an error on xstddef as:
88
+ ## 'auto' return without trailing return type; deduced return types are a C++14 extension
89
+ if host_machine .system() == ' windows'
90
+ message (' [WINDOWS] using c++14 standard' )
91
+ sqlitecpp_opts += [
92
+ ' cpp_std=c++14' ,
93
+ ]
94
+ endif
82
95
# Options relative to SQLite and SQLiteC++ functions
83
96
84
97
if get_option (' SQLITE_ENABLE_COLUMN_METADATA' )
@@ -131,10 +144,23 @@ libsqlitecpp = library(
131
144
include_directories : sqlitecpp_incl,
132
145
cpp_args : sqlitecpp_args,
133
146
dependencies : sqlitecpp_deps,
147
+ # override the default options
148
+ override_options : sqlitecpp_opts,
134
149
# install: true,
135
150
# API version for SQLiteCpp shared library.
136
- version : ' 0' ,
137
- )
151
+ version : ' 0' ,)
152
+ if get_option (' SQLITECPP_BUILD_TESTS' )
153
+ # for the unit tests we need to link against a static version of SQLiteCpp
154
+ libsqlitecpp_static = static_library (
155
+ ' sqlitecpp_static' ,
156
+ sqlitecpp_srcs,
157
+ include_directories : sqlitecpp_incl,
158
+ cpp_args : sqlitecpp_args,
159
+ dependencies : sqlitecpp_deps,
160
+ # override the default options
161
+ override_options : sqlitecpp_opts,)
162
+ # static libraries do not have a version
163
+ endif
138
164
139
165
install_headers (
140
166
' include/SQLiteCpp/SQLiteCpp.h' ,
@@ -153,6 +179,14 @@ sqlitecpp_dep = declare_dependency(
153
179
include_directories : sqlitecpp_incl,
154
180
link_with : libsqlitecpp,
155
181
)
182
+ if get_option (' SQLITECPP_BUILD_TESTS' )
183
+ ## make the dependency static so the unit tests can link against it
184
+ ## (mainly for windows as the symbols are not exported by default)
185
+ sqlitecpp_static_dep = declare_dependency (
186
+ include_directories : sqlitecpp_incl,
187
+ link_with : libsqlitecpp_static,
188
+ )
189
+ endif
156
190
157
191
if get_option (' SQLITECPP_BUILD_TESTS' )
158
192
gtest_dep = dependency (
@@ -161,13 +195,15 @@ if get_option('SQLITECPP_BUILD_TESTS')
161
195
fallback : [' gtest' , ' gtest_dep' ])
162
196
sqlitecpp_test_dependencies = [
163
197
gtest_dep,
164
- sqlitecpp_dep ,
198
+ sqlitecpp_static_dep ,
165
199
sqlite3_dep,
166
200
]
167
- sqlitecpp_test_args = []
168
201
169
202
testexe = executable (' testexe' , sqlitecpp_test_srcs,
170
- dependencies : sqlitecpp_test_dependencies)
203
+ dependencies : sqlitecpp_test_dependencies,
204
+ cpp_args : sqlitecpp_test_args,
205
+ # override the default options
206
+ override_options : sqlitecpp_opts,)
171
207
172
208
test_args = []
173
209
@@ -177,7 +213,9 @@ if get_option('SQLITECPP_BUILD_EXAMPLES')
177
213
## demo executable
178
214
sqlitecpp_demo_exe = executable (' SQLITECPP_sample_demo' ,
179
215
sqlitecpp_sample_srcs,
180
- dependencies : sqlitecpp_dep)
216
+ dependencies : sqlitecpp_dep,
217
+ # override the default options
218
+ override_options : sqlitecpp_opts,)
181
219
endif
182
220
183
221
pkgconfig = import (' pkgconfig' )
0 commit comments