From e32daec169af42fcf401e636c1653dcf590d88e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Tue, 19 Apr 2022 22:03:40 -0600 Subject: [PATCH] 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 --- meson.build | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 81058e1..fb6f658 100644 --- a/meson.build +++ b/meson.build @@ -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, ]