From 5e8cdbeb38fd4eba79afdd401a5f18637b8fe3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Wed, 7 Dec 2022 20:42:43 -0600 Subject: [PATCH 01/13] add explanations for samples in meson --- meson_options.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson_options.txt b/meson_options.txt index b5e9f4a..c9d80af 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,5 +9,7 @@ option('SQLITE_ENABLE_ASSERT_HANDLER', type: 'boolean', value: false, descriptio option('SQLITE_HAS_CODEC', type: 'boolean', value: false, description: 'Enable database encryption API. Not available in the public release of SQLite.') ## Force forward declaration of legacy struct sqlite3_value (pre SQLite 3.19) option('SQLITE_USE_LEGACY_STRUCT', type: 'boolean', value: false, description: 'Fallback to forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)') +## Enable build for the tests of SQLiteC++ option('SQLITECPP_BUILD_TESTS', type: 'boolean', value: false, description: 'Build SQLiteC++ unit tests.') +## Build the examples of SQLiteC++ option('SQLITECPP_BUILD_EXAMPLES', type: 'boolean', value: false, description: 'Build SQLiteC++ examples.') \ No newline at end of file From 02d43dc4f1cc2b23f3b713b79c91fa8f27e5f231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Wed, 7 Dec 2022 20:43:29 -0600 Subject: [PATCH 02/13] ignore clangd cache --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ac9a66e..60ea585 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ Release build *.a +# ignore clangd cache directory +.cache .vs/ .vscode/ /SQLiteCpp.sln From d639f6b86ca9cf48118210929845285e7d36475c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Wed, 7 Dec 2022 20:45:40 -0600 Subject: [PATCH 03/13] change meson version to 3.2.0 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index fb6f658..8f3da91 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( # SQLiteCpp requires C++11 support default_options: ['cpp_std=c++11'], license: 'MIT', - version: '3.1.1', + version: '3.2.0', ) cxx = meson.get_compiler('cpp') From 44d63d74851b3de2e692c3ad993d476dbb6a5801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Wed, 7 Dec 2022 20:56:02 -0600 Subject: [PATCH 04/13] [Meson] update gtest version to 1.12.1 --- subprojects/gtest.wrap | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap index 65df9f1..6d463a7 100644 --- a/subprojects/gtest.wrap +++ b/subprojects/gtest.wrap @@ -1,9 +1,12 @@ [wrap-file] -directory = googletest-release-1.11.0 -source_url = https://github.com/google/googletest/archive/release-1.11.0.tar.gz -source_filename = gtest-1.11.0.tar.gz -source_hash = b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5 -patch_directory = gtest +directory = googletest-release-1.12.1 +source_url = https://github.com/google/googletest/archive/release-1.12.1.tar.gz +source_filename = gtest-1.12.1.tar.gz +source_hash = 81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2 +patch_filename = gtest_1.12.1-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.12.1-1/get_patch +patch_hash = 75143f11e174952bc768699fde3176511fe8e33b25dc6f6347d89e41648e99cf +wrapdb_version = 1.12.1-1 [provide] gtest = gtest_dep From 70b15f9de8f0cf07f416dc858144b623646ccf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Wed, 7 Dec 2022 21:37:51 -0600 Subject: [PATCH 05/13] [Meson] use gtest_main for fallback --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8f3da91..7a01543 100644 --- a/meson.build +++ b/meson.build @@ -192,7 +192,7 @@ if get_option('SQLITECPP_BUILD_TESTS') gtest_dep = dependency( 'gtest', main : true, - fallback: ['gtest', 'gtest_dep']) + fallback: ['gtest', 'gtest_main_dep']) sqlitecpp_test_dependencies = [ gtest_dep, sqlitecpp_static_dep, From 223192309477f2da3550312fd35319b2a6e8a20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Wed, 7 Dec 2022 21:50:57 -0600 Subject: [PATCH 06/13] remove NON_AMBIGUOUS_OVERLOAD this macro is no longer needed for the tests as part of the cleanup in commit 091726aa65a059004dcbda16095c58fd7fc8781c --- meson.build | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 7a01543..f28c5fb 100644 --- a/meson.build +++ b/meson.build @@ -61,10 +61,7 @@ sqlitecpp_test_srcs = [ 'tests/Exception_test.cpp', 'tests/ExecuteMany_test.cpp', ] -sqlitecpp_test_args = [ - # do not use ambiguous overloads by default - '-DNON_AMBIGOUS_OVERLOAD' -] +sqlitecpp_test_args = [] ## samples From 85eace84f273beee39d8377884848bf38cd7fc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 00:05:27 -0600 Subject: [PATCH 07/13] [meson] add savepoint support --- meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meson.build b/meson.build index f28c5fb..bfc427a 100644 --- a/meson.build +++ b/meson.build @@ -35,6 +35,7 @@ sqlitecpp_srcs = [ 'src/Column.cpp', 'src/Database.cpp', 'src/Exception.cpp', + 'src/Savepoint.cpp' 'src/Statement.cpp', 'src/Transaction.cpp', ] @@ -54,6 +55,7 @@ sqlitecpp_opts = [] sqlitecpp_test_srcs = [ 'tests/Column_test.cpp', 'tests/Database_test.cpp', + 'tests/Savepoint_test.cpp', 'tests/Statement_test.cpp', 'tests/Backup_test.cpp', 'tests/Transaction_test.cpp', @@ -166,6 +168,7 @@ install_headers( 'include/SQLiteCpp/Column.h', 'include/SQLiteCpp/Database.h', 'include/SQLiteCpp/Exception.h', + 'include/SQLiteCpp/Savepoint.h', 'include/SQLiteCpp/Statement.h', 'include/SQLiteCpp/Transaction.h', 'include/SQLiteCpp/VariadicBind.h', From ca985c30dc3f7c57a6a70e442755fb1aac0593b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 00:13:50 -0600 Subject: [PATCH 08/13] install headers on proper subdir --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index bfc427a..82a08c2 100644 --- a/meson.build +++ b/meson.build @@ -173,6 +173,7 @@ install_headers( 'include/SQLiteCpp/Transaction.h', 'include/SQLiteCpp/VariadicBind.h', 'include/SQLiteCpp/ExecuteMany.h', + subdir : 'SQLiteCpp', ) sqlitecpp_dep = declare_dependency( From 47d9a31e4e208e2df32340074c68807b6c1f11db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 12:40:51 -0600 Subject: [PATCH 09/13] [meson] install headers by using install_subdir use install_subdir instead of the install_headers in the meson config file --- meson.build | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 82a08c2..a617448 100644 --- a/meson.build +++ b/meson.build @@ -161,20 +161,9 @@ if get_option('SQLITECPP_BUILD_TESTS') # static libraries do not have a version endif -install_headers( - 'include/SQLiteCpp/SQLiteCpp.h', - 'include/SQLiteCpp/Assertion.h', - 'include/SQLiteCpp/Backup.h', - 'include/SQLiteCpp/Column.h', - 'include/SQLiteCpp/Database.h', - 'include/SQLiteCpp/Exception.h', - 'include/SQLiteCpp/Savepoint.h', - 'include/SQLiteCpp/Statement.h', - 'include/SQLiteCpp/Transaction.h', - 'include/SQLiteCpp/VariadicBind.h', - 'include/SQLiteCpp/ExecuteMany.h', - subdir : 'SQLiteCpp', -) +install_subdir( + 'include/SQliteCpp', + install_dir: get_option('includedir')) sqlitecpp_dep = declare_dependency( include_directories: sqlitecpp_incl, From 5cd06993027b9a3000f967faf0cbe8f525e61d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 18:55:08 -0600 Subject: [PATCH 10/13] add sample 2 demo executable --- meson.build | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index a617448..9bec9af 100644 --- a/meson.build +++ b/meson.build @@ -67,9 +67,12 @@ sqlitecpp_test_args = [] ## samples -sqlitecpp_sample_srcs = [ +sqlitecpp_sample1_srcs = [ 'examples/example1/main.cpp', ] +sqlitecpp_sample2_srcs = [ + 'examples/example2/src/main.cpp', +] # if not using MSVC we need to add this compiler arguments # for a list of MSVC supported arguments please check: @@ -200,12 +203,19 @@ if get_option('SQLITECPP_BUILD_TESTS') test('sqlitecpp unit tests', testexe, args: test_args) endif if get_option('SQLITECPP_BUILD_EXAMPLES') - ## demo executable - sqlitecpp_demo_exe = executable('SQLITECPP_sample_demo', - sqlitecpp_sample_srcs, + ## demo 1 executable + sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo1', + sqlitecpp_sample1_srcs, dependencies: sqlitecpp_dep, # override the default options override_options: sqlitecpp_opts,) + ## demo 2 executable + sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo2', + sqlitecpp_sample2_srcs, + dependencies: sqlitecpp_dep, + # override the default options + override_options: sqlitecpp_opts,) + endif pkgconfig = import('pkgconfig') From 57ebdb25fcc1e27ddd2b51f9511bab40a4a1a642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 20:09:24 -0600 Subject: [PATCH 11/13] add missing trailing comma --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 9bec9af..9c3bab0 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,7 @@ sqlitecpp_srcs = [ 'src/Column.cpp', 'src/Database.cpp', 'src/Exception.cpp', - 'src/Savepoint.cpp' + 'src/Savepoint.cpp', 'src/Statement.cpp', 'src/Transaction.cpp', ] From b73d8446beafba8d1a0a066d9788f685378f44b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 22:03:58 -0600 Subject: [PATCH 12/13] ignore cmakesettings.json --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 60ea585..811cd56 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ core *ipch .settings/ +# do not track Visual Studio CMake settings +CMakeSettings.json CMakeCache.txt CMakeFiles *.dir From bd2e1c6087686b1fab147bbc60e46335c1ce641a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Thu, 8 Dec 2022 22:17:17 -0600 Subject: [PATCH 13/13] [Meson] build library as static on windows as dynamic linking is not supported on windows we can give a warning and compile the library as static itself --- meson.build | 55 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/meson.build b/meson.build index 9c3bab0..9b3ba42 100644 --- a/meson.build +++ b/meson.build @@ -93,6 +93,11 @@ if host_machine.system() == 'windows' sqlitecpp_opts += [ 'cpp_std=c++14', ] + # check that we are not trying to build as dynamic library + if get_option('default_library') != 'shared' + warming('SQLiteCpp does not support shared library on Windows, the library will be built as static') + endif + endif # Options relative to SQLite and SQLiteC++ functions @@ -139,29 +144,45 @@ if get_option('b_coverage') ] endif - -libsqlitecpp = library( - 'sqlitecpp', - sqlitecpp_srcs, - include_directories: sqlitecpp_incl, - cpp_args: sqlitecpp_args, - dependencies: sqlitecpp_deps, - # override the default options - override_options: sqlitecpp_opts, - # 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', +## Workarround for windows: if building on windows we will build the library as static +if host_machine.system() == 'windows' + libsqlitecpp = static_library( + 'sqlitecpp', 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 +else + libsqlitecpp = library( + 'sqlitecpp', + sqlitecpp_srcs, + include_directories: sqlitecpp_incl, + cpp_args: sqlitecpp_args, + dependencies: sqlitecpp_deps, + # override the default options + override_options: sqlitecpp_opts, + # install: true, + # API version for SQLiteCpp shared library. + version: '0',) +endif + +if get_option('SQLITECPP_BUILD_TESTS') + # for the unit tests we need to link against a static version of SQLiteCpp + if host_machine.system() == 'windows' or get_option('default_library') == 'static' + # we do not need to recomplile the library + libsqlitecpp_static = libsqlitecpp + else + 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,) + endif endif install_subdir(