@@ -46,6 +46,8 @@ sqlitecpp_deps = [
4646 sqlite3_dep,
4747 thread_dep,
4848]
49+ ## used to override the default sqlitecpp options like cpp standard
50+ sqlitecpp_opts = []
4951
5052## tests
5153
@@ -59,6 +61,10 @@ sqlitecpp_test_srcs = [
5961 ' tests/Exception_test.cpp' ,
6062 ' tests/ExecuteMany_test.cpp' ,
6163]
64+ sqlitecpp_test_args = [
65+ # do not use ambiguous overloads by default
66+ ' -DNON_AMBIGOUS_OVERLOAD'
67+ ]
6268
6369## samples
6470
@@ -78,7 +84,14 @@ if not (host_machine.system() == 'windows' and cxx.get_id() == 'msvc')
7884 ' -Wno-long-long' ,
7985 ]
8086endif
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
8295# Options relative to SQLite and SQLiteC++ functions
8396
8497if get_option (' SQLITE_ENABLE_COLUMN_METADATA' )
@@ -131,10 +144,23 @@ libsqlitecpp = library(
131144 include_directories : sqlitecpp_incl,
132145 cpp_args : sqlitecpp_args,
133146 dependencies : sqlitecpp_deps,
147+ # override the default options
148+ override_options : sqlitecpp_opts,
134149 # install: true,
135150 # 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
138164
139165install_headers (
140166 ' include/SQLiteCpp/SQLiteCpp.h' ,
@@ -153,6 +179,14 @@ sqlitecpp_dep = declare_dependency(
153179 include_directories : sqlitecpp_incl,
154180 link_with : libsqlitecpp,
155181)
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
156190
157191if get_option (' SQLITECPP_BUILD_TESTS' )
158192 gtest_dep = dependency (
@@ -161,13 +195,15 @@ if get_option('SQLITECPP_BUILD_TESTS')
161195 fallback : [' gtest' , ' gtest_dep' ])
162196 sqlitecpp_test_dependencies = [
163197 gtest_dep,
164- sqlitecpp_dep ,
198+ sqlitecpp_static_dep ,
165199 sqlite3_dep,
166200 ]
167- sqlitecpp_test_args = []
168201
169202 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,)
171207
172208 test_args = []
173209
@@ -177,7 +213,9 @@ if get_option('SQLITECPP_BUILD_EXAMPLES')
177213 ## demo executable
178214 sqlitecpp_demo_exe = executable (' SQLITECPP_sample_demo' ,
179215 sqlitecpp_sample_srcs,
180- dependencies : sqlitecpp_dep)
216+ dependencies : sqlitecpp_dep,
217+ # override the default options
218+ override_options : sqlitecpp_opts,)
181219endif
182220
183221pkgconfig = import (' pkgconfig' )
0 commit comments