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, ]