@@ -65,6 +65,8 @@ sqlitecpp_deps = [
65
65
]
66
66
## used to override the default sqlitecpp options like cpp standard
67
67
sqlitecpp_opts = []
68
+ ## used to set required macros when using sqlitecpp
69
+ sqlitecpp_dep_args = []
68
70
69
71
## tests
70
72
@@ -97,11 +99,6 @@ if host_machine.system() == 'windows'
97
99
sqlitecpp_opts += [
98
100
' cpp_std=c++14' ,
99
101
]
100
- # check that we are not trying to build as dynamic library
101
- if get_option (' default_library' ) != ' shared'
102
- message (' warning: SQLiteCpp does not support shared library on Windows, the library will be built as static' )
103
- endif
104
-
105
102
endif
106
103
# Options relative to SQLite and SQLiteC++ functions
107
104
@@ -199,41 +196,44 @@ if get_option('b_coverage')
199
196
]
200
197
endif
201
198
202
- ## Workarround for windows: if building on windows we will build the library as static
203
- if host_machine .system() == ' windows'
204
- libsqlitecpp = static_library (
205
- ' sqlitecpp' ,
206
- sqlitecpp_srcs,
207
- include_directories : sqlitecpp_incl,
208
- cpp_args : sqlitecpp_args,
209
- dependencies : sqlitecpp_deps,
210
- # override the default options
211
- override_options : sqlitecpp_opts,)
212
- else
213
- libsqlitecpp = library (
214
- ' sqlitecpp' ,
215
- sqlitecpp_srcs,
216
- include_directories : sqlitecpp_incl,
217
- cpp_args : sqlitecpp_args,
218
- dependencies : sqlitecpp_deps,
219
- # override the default options
220
- override_options : sqlitecpp_opts,
221
- install : true ,
222
- # API version for SQLiteCpp shared library.
223
- version : ' 0' ,)
199
+ sqlitecpp_static_args = sqlitecpp_args
200
+ sqlitecpp_static_dep_args = sqlitecpp_dep_args
201
+ # if windows and shared library
202
+ if host_machine .system() == ' windows' and get_option (' default_library' ) == ' shared'
203
+ # compile with SQLITECPP_COMPILE_DLL and SQLITECPP_DLL_EXPORT=1
204
+ sqlitecpp_args += [
205
+ ' -DSQLITECPP_COMPILE_DLL' ,
206
+ ' -DSQLITECPP_DLL_EXPORT' ,
207
+ ]
208
+ sqlitecpp_dep_args += [
209
+ # we just need to define SQLITECPP_COMPILE_DLL
210
+ ' -DSQLITECPP_COMPILE_DLL' ,
211
+ ]
224
212
endif
225
213
214
+ libsqlitecpp = library (
215
+ ' sqlitecpp' ,
216
+ sqlitecpp_srcs,
217
+ include_directories : sqlitecpp_incl,
218
+ cpp_args : sqlitecpp_args,
219
+ dependencies : sqlitecpp_deps,
220
+ # override the default options
221
+ override_options : sqlitecpp_opts,
222
+ install : true ,
223
+ # API version for SQLiteCpp shared library.
224
+ version : ' 0' ,)
225
+
226
226
if get_option (' SQLITECPP_BUILD_TESTS' )
227
227
# for the unit tests we need to link against a static version of SQLiteCpp
228
- if host_machine .system() == ' windows ' or get_option (' default_library' ) == ' static'
228
+ if get_option (' default_library' ) == ' static'
229
229
# we do not need to recomplile the library
230
230
libsqlitecpp_static = libsqlitecpp
231
231
else
232
232
libsqlitecpp_static = static_library (
233
233
' sqlitecpp_static' ,
234
234
sqlitecpp_srcs,
235
235
include_directories : sqlitecpp_incl,
236
- cpp_args : sqlitecpp_args ,
236
+ cpp_args : sqlitecpp_static_args ,
237
237
dependencies : sqlitecpp_deps,
238
238
# override the default options
239
239
override_options : sqlitecpp_opts,)
@@ -247,13 +247,14 @@ install_subdir(
247
247
sqlitecpp_dep = declare_dependency (
248
248
include_directories : sqlitecpp_incl,
249
249
link_with : libsqlitecpp,
250
+ compile_args : sqlitecpp_dep_args,
250
251
)
251
252
if get_option (' SQLITECPP_BUILD_TESTS' )
252
253
## make the dependency static so the unit tests can link against it
253
- ## (mainly for windows as the symbols are not exported by default)
254
254
sqlitecpp_static_dep = declare_dependency (
255
255
include_directories : sqlitecpp_incl,
256
256
link_with : libsqlitecpp_static,
257
+ compile_args : sqlitecpp_static_dep_args,
257
258
)
258
259
endif
259
260
@@ -264,7 +265,7 @@ if get_option('SQLITECPP_BUILD_TESTS')
264
265
fallback : [' gtest' , ' gtest_main_dep' ])
265
266
sqlitecpp_test_dependencies = [
266
267
gtest_dep,
267
- sqlitecpp_static_dep ,
268
+ sqlitecpp_dep ,
268
269
sqlite3_dep,
269
270
]
270
271
0 commit comments