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
This commit is contained in:
Jonathan Guzmán
2022-04-19 22:03:40 -06:00
parent 9f5d446e36
commit e32daec169

View File

@@ -149,6 +149,18 @@ libsqlitecpp = library(
# install: true,
# API version for SQLiteCpp shared library.
version: '0',)
if get_option('SQLITECPP_BUILD_TESTS')
# for the unit tests we need to link against a static version of SQLiteCpp
libsqlitecpp_static = static_library(
'sqlitecpp_static',
sqlitecpp_srcs,
include_directories: sqlitecpp_incl,
cpp_args: sqlitecpp_args,
dependencies: sqlitecpp_deps,
# override the default options
override_options: sqlitecpp_opts,)
# static libraries do not have a version
endif
install_headers(
'include/SQLiteCpp/SQLiteCpp.h',
@@ -167,6 +179,14 @@ sqlitecpp_dep = declare_dependency(
include_directories: sqlitecpp_incl,
link_with: libsqlitecpp,
)
if get_option('SQLITECPP_BUILD_TESTS')
## make the dependency static so the unit tests can link against it
## (mainly for windows as the symbols are not exported by default)
sqlitecpp_static_dep = declare_dependency(
include_directories: sqlitecpp_incl,
link_with: libsqlitecpp_static,
)
endif
if get_option('SQLITECPP_BUILD_TESTS')
gtest_dep = dependency(
@@ -175,7 +195,7 @@ if get_option('SQLITECPP_BUILD_TESTS')
fallback: ['gtest', 'gtest_dep'])
sqlitecpp_test_dependencies = [
gtest_dep,
sqlitecpp_dep,
sqlitecpp_static_dep,
sqlite3_dep,
]