Skip to content

Commit e32daec

Browse files
committed
link library statically when building unit tests
make the meson file link statically the library when building the unit tests executable so it does not fail on windows as the symbols are not exported by default
1 parent 9f5d446 commit e32daec

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

meson.build

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ libsqlitecpp = library(
149149
# install: true,
150150
# API version for SQLiteCpp shared library.
151151
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
152164

153165
install_headers(
154166
'include/SQLiteCpp/SQLiteCpp.h',
@@ -167,6 +179,14 @@ sqlitecpp_dep = declare_dependency(
167179
include_directories: sqlitecpp_incl,
168180
link_with: libsqlitecpp,
169181
)
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
170190

171191
if get_option('SQLITECPP_BUILD_TESTS')
172192
gtest_dep = dependency(
@@ -175,7 +195,7 @@ if get_option('SQLITECPP_BUILD_TESTS')
175195
fallback: ['gtest', 'gtest_dep'])
176196
sqlitecpp_test_dependencies = [
177197
gtest_dep,
178-
sqlitecpp_dep,
198+
sqlitecpp_static_dep,
179199
sqlite3_dep,
180200
]
181201

0 commit comments

Comments
 (0)