Skip to content

Commit 4fc2eee

Browse files
authored
Merge pull request #380 [Meson] fixes for meson project from ninjaoflight/windows-support
2 parents a32e884 + bd2e1c6 commit 4fc2eee

File tree

4 files changed

+74
-44
lines changed

4 files changed

+74
-44
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Release
33
build
44
*.a
55

6+
# ignore clangd cache directory
7+
.cache
68
.vs/
79
.vscode/
810
/SQLiteCpp.sln
@@ -17,6 +19,8 @@ core
1719
*ipch
1820
.settings/
1921

22+
# do not track Visual Studio CMake settings
23+
CMakeSettings.json
2024
CMakeCache.txt
2125
CMakeFiles
2226
*.dir

meson.build

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project(
33
# SQLiteCpp requires C++11 support
44
default_options: ['cpp_std=c++11'],
55
license: 'MIT',
6-
version: '3.1.1',
6+
version: '3.2.0',
77
)
88

99
cxx = meson.get_compiler('cpp')
@@ -35,6 +35,7 @@ sqlitecpp_srcs = [
3535
'src/Column.cpp',
3636
'src/Database.cpp',
3737
'src/Exception.cpp',
38+
'src/Savepoint.cpp',
3839
'src/Statement.cpp',
3940
'src/Transaction.cpp',
4041
]
@@ -54,23 +55,24 @@ sqlitecpp_opts = []
5455
sqlitecpp_test_srcs = [
5556
'tests/Column_test.cpp',
5657
'tests/Database_test.cpp',
58+
'tests/Savepoint_test.cpp',
5759
'tests/Statement_test.cpp',
5860
'tests/Backup_test.cpp',
5961
'tests/Transaction_test.cpp',
6062
'tests/VariadicBind_test.cpp',
6163
'tests/Exception_test.cpp',
6264
'tests/ExecuteMany_test.cpp',
6365
]
64-
sqlitecpp_test_args = [
65-
# do not use ambiguous overloads by default
66-
'-DNON_AMBIGOUS_OVERLOAD'
67-
]
66+
sqlitecpp_test_args = []
6867

6968
## samples
7069

71-
sqlitecpp_sample_srcs = [
70+
sqlitecpp_sample1_srcs = [
7271
'examples/example1/main.cpp',
7372
]
73+
sqlitecpp_sample2_srcs = [
74+
'examples/example2/src/main.cpp',
75+
]
7476

7577
# if not using MSVC we need to add this compiler arguments
7678
# for a list of MSVC supported arguments please check:
@@ -91,6 +93,11 @@ if host_machine.system() == 'windows'
9193
sqlitecpp_opts += [
9294
'cpp_std=c++14',
9395
]
96+
# check that we are not trying to build as dynamic library
97+
if get_option('default_library') != 'shared'
98+
warming('SQLiteCpp does not support shared library on Windows, the library will be built as static')
99+
endif
100+
94101
endif
95102
# Options relative to SQLite and SQLiteC++ functions
96103

@@ -137,43 +144,50 @@ if get_option('b_coverage')
137144
]
138145
endif
139146

140-
141-
libsqlitecpp = library(
142-
'sqlitecpp',
143-
sqlitecpp_srcs,
144-
include_directories: sqlitecpp_incl,
145-
cpp_args: sqlitecpp_args,
146-
dependencies: sqlitecpp_deps,
147-
# override the default options
148-
override_options: sqlitecpp_opts,
149-
# install: true,
150-
# API version for SQLiteCpp shared library.
151-
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',
147+
## Workarround for windows: if building on windows we will build the library as static
148+
if host_machine.system() == 'windows'
149+
libsqlitecpp = static_library(
150+
'sqlitecpp',
156151
sqlitecpp_srcs,
157152
include_directories: sqlitecpp_incl,
158153
cpp_args: sqlitecpp_args,
159154
dependencies: sqlitecpp_deps,
160155
# override the default options
161156
override_options: sqlitecpp_opts,)
162-
# static libraries do not have a version
157+
else
158+
libsqlitecpp = library(
159+
'sqlitecpp',
160+
sqlitecpp_srcs,
161+
include_directories: sqlitecpp_incl,
162+
cpp_args: sqlitecpp_args,
163+
dependencies: sqlitecpp_deps,
164+
# override the default options
165+
override_options: sqlitecpp_opts,
166+
# install: true,
167+
# API version for SQLiteCpp shared library.
168+
version: '0',)
163169
endif
164170

165-
install_headers(
166-
'include/SQLiteCpp/SQLiteCpp.h',
167-
'include/SQLiteCpp/Assertion.h',
168-
'include/SQLiteCpp/Backup.h',
169-
'include/SQLiteCpp/Column.h',
170-
'include/SQLiteCpp/Database.h',
171-
'include/SQLiteCpp/Exception.h',
172-
'include/SQLiteCpp/Statement.h',
173-
'include/SQLiteCpp/Transaction.h',
174-
'include/SQLiteCpp/VariadicBind.h',
175-
'include/SQLiteCpp/ExecuteMany.h',
176-
)
171+
if get_option('SQLITECPP_BUILD_TESTS')
172+
# for the unit tests we need to link against a static version of SQLiteCpp
173+
if host_machine.system() == 'windows' or get_option('default_library') == 'static'
174+
# we do not need to recomplile the library
175+
libsqlitecpp_static = libsqlitecpp
176+
else
177+
libsqlitecpp_static = static_library(
178+
'sqlitecpp_static',
179+
sqlitecpp_srcs,
180+
include_directories: sqlitecpp_incl,
181+
cpp_args: sqlitecpp_args,
182+
dependencies: sqlitecpp_deps,
183+
# override the default options
184+
override_options: sqlitecpp_opts,)
185+
endif
186+
endif
187+
188+
install_subdir(
189+
'include/SQliteCpp',
190+
install_dir: get_option('includedir'))
177191

178192
sqlitecpp_dep = declare_dependency(
179193
include_directories: sqlitecpp_incl,
@@ -192,7 +206,7 @@ if get_option('SQLITECPP_BUILD_TESTS')
192206
gtest_dep = dependency(
193207
'gtest',
194208
main : true,
195-
fallback: ['gtest', 'gtest_dep'])
209+
fallback: ['gtest', 'gtest_main_dep'])
196210
sqlitecpp_test_dependencies = [
197211
gtest_dep,
198212
sqlitecpp_static_dep,
@@ -210,12 +224,19 @@ if get_option('SQLITECPP_BUILD_TESTS')
210224
test('sqlitecpp unit tests', testexe, args: test_args)
211225
endif
212226
if get_option('SQLITECPP_BUILD_EXAMPLES')
213-
## demo executable
214-
sqlitecpp_demo_exe = executable('SQLITECPP_sample_demo',
215-
sqlitecpp_sample_srcs,
227+
## demo 1 executable
228+
sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo1',
229+
sqlitecpp_sample1_srcs,
230+
dependencies: sqlitecpp_dep,
231+
# override the default options
232+
override_options: sqlitecpp_opts,)
233+
## demo 2 executable
234+
sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo2',
235+
sqlitecpp_sample2_srcs,
216236
dependencies: sqlitecpp_dep,
217237
# override the default options
218238
override_options: sqlitecpp_opts,)
239+
219240
endif
220241

221242
pkgconfig = import('pkgconfig')

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ option('SQLITE_ENABLE_ASSERT_HANDLER', type: 'boolean', value: false, descriptio
99
option('SQLITE_HAS_CODEC', type: 'boolean', value: false, description: 'Enable database encryption API. Not available in the public release of SQLite.')
1010
## Force forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)
1111
option('SQLITE_USE_LEGACY_STRUCT', type: 'boolean', value: false, description: 'Fallback to forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)')
12+
## Enable build for the tests of SQLiteC++
1213
option('SQLITECPP_BUILD_TESTS', type: 'boolean', value: false, description: 'Build SQLiteC++ unit tests.')
14+
## Build the examples of SQLiteC++
1315
option('SQLITECPP_BUILD_EXAMPLES', type: 'boolean', value: false, description: 'Build SQLiteC++ examples.')

subprojects/gtest.wrap

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[wrap-file]
2-
directory = googletest-release-1.11.0
3-
source_url = https://github.com/google/googletest/archive/release-1.11.0.tar.gz
4-
source_filename = gtest-1.11.0.tar.gz
5-
source_hash = b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5
6-
patch_directory = gtest
2+
directory = googletest-release-1.12.1
3+
source_url = https://github.com/google/googletest/archive/release-1.12.1.tar.gz
4+
source_filename = gtest-1.12.1.tar.gz
5+
source_hash = 81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2
6+
patch_filename = gtest_1.12.1-1_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.12.1-1/get_patch
8+
patch_hash = 75143f11e174952bc768699fde3176511fe8e33b25dc6f6347d89e41648e99cf
9+
wrapdb_version = 1.12.1-1
710

811
[provide]
912
gtest = gtest_dep

0 commit comments

Comments
 (0)