Skip to content

Commit 1eca00c

Browse files
committed
Fixed meson build thanks to @ninjaoflight
1 parent 6110463 commit 1eca00c

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

meson.build

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ sqlitecpp_deps = [
6565
]
6666
## used to override the default sqlitecpp options like cpp standard
6767
sqlitecpp_opts = []
68+
## used to set required macros when using sqlitecpp
69+
sqlitecpp_dep_args = []
6870

6971
## tests
7072

@@ -97,11 +99,6 @@ if host_machine.system() == 'windows'
9799
sqlitecpp_opts += [
98100
'cpp_std=c++14',
99101
]
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-
105102
endif
106103
# Options relative to SQLite and SQLiteC++ functions
107104

@@ -199,41 +196,44 @@ if get_option('b_coverage')
199196
]
200197
endif
201198

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+
]
224212
endif
225213

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+
226226
if get_option('SQLITECPP_BUILD_TESTS')
227227
# 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'
229229
# we do not need to recomplile the library
230230
libsqlitecpp_static = libsqlitecpp
231231
else
232232
libsqlitecpp_static = static_library(
233233
'sqlitecpp_static',
234234
sqlitecpp_srcs,
235235
include_directories: sqlitecpp_incl,
236-
cpp_args: sqlitecpp_args,
236+
cpp_args: sqlitecpp_static_args,
237237
dependencies: sqlitecpp_deps,
238238
# override the default options
239239
override_options: sqlitecpp_opts,)
@@ -247,13 +247,14 @@ install_subdir(
247247
sqlitecpp_dep = declare_dependency(
248248
include_directories: sqlitecpp_incl,
249249
link_with: libsqlitecpp,
250+
compile_args: sqlitecpp_dep_args,
250251
)
251252
if get_option('SQLITECPP_BUILD_TESTS')
252253
## make the dependency static so the unit tests can link against it
253-
## (mainly for windows as the symbols are not exported by default)
254254
sqlitecpp_static_dep = declare_dependency(
255255
include_directories: sqlitecpp_incl,
256256
link_with: libsqlitecpp_static,
257+
compile_args: sqlitecpp_static_dep_args,
257258
)
258259
endif
259260

@@ -264,7 +265,7 @@ if get_option('SQLITECPP_BUILD_TESTS')
264265
fallback: ['gtest', 'gtest_main_dep'])
265266
sqlitecpp_test_dependencies = [
266267
gtest_dep,
267-
sqlitecpp_static_dep,
268+
sqlitecpp_dep,
268269
sqlite3_dep,
269270
]
270271

0 commit comments

Comments
 (0)