From 841247f061b3cff071bb0f3794418fe29e47eb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Fri, 16 Dec 2022 21:13:54 -0600 Subject: [PATCH 1/3] add meson usage guide --- README.md | 56 +++++++++++++++++++++++++++++++++++ examples/example1/meson.build | 20 +++++++++++++ examples/example2/meson.build | 20 +++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 examples/example1/meson.build create mode 100644 examples/example2/meson.build diff --git a/README.md b/README.md index 1274a41..a5693bd 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,62 @@ cmake --build . ctest --output-on-failure ``` +#### Building with meson + +You can build SQLiteCpp with [meson](https://mesonbuild.com/) using the provided meson project. + +you can install meson using pip: `pip install meson` however you may need to install ninja and other dependencies depending on your platform as an compiler toolchain + +Arch Linux: + +```sh +# install clang (compiler toolchain) and ninja (recommended build system) +sudo pacman -Syu clang ninja +# install python and pip (required for meson) +sudo pacman -Syu python python-pip +# install meson +pip install meson +``` + +Ubuntu: + +```sh +# install gcc(compiler toolchain) and ninja (recommended build system) +sudo apt install build-essential ninja-build +# install python and pip (required for meson) +sudo apt install python3 python3-pip +# install meson +pip install meson +``` + +for example you can build the library using the default options with: + +```sh +# setup the build directory +meson setup builddir +# build sqlitecpp +meson compile -C builddir +``` + +or if you wish to build with tests and examples: + +```sh +# setup the build directory with tests and examples enabled +meson setup builddir -DSQLITECPP_BUILD_TESTS=true -DSQLITECPP_BUILD_EXAMPLES=true +# build sqlitecpp +meson compile -C builddir +``` + +#### Using SQLiteCpp as subproject in meson + +please check the examples in the examples folder for usage of SQLiteCpp as a subproject in meson, as for the wrap file you can use the one provided in the subprojects folder called `SQLiteCpp.wrap` + +> keep in mind that even that this wrap should be up to date, it is recommended to check the latest version of SQLiteCpp and update the wrap file accordingly + +#### System SQLiteCpp support under meson + +additionally meson can detect and use the bundled sqlitecpp library included on your system if available, for example with vcpkg you would need to set the `PKG_CONFIG_PATH` environment variable to the vcpkg directory before running meson setup, and if applies the corresponding `PKG-CONFIG` executable to the path. + #### Building the Doxygen/html documentation Make sure you have Dogygen installed and configure CMake using the `SQLITECPP_RUN_DOXYGEN=ON` flag: diff --git a/examples/example1/meson.build b/examples/example1/meson.build new file mode 100644 index 0000000..bd4931a --- /dev/null +++ b/examples/example1/meson.build @@ -0,0 +1,20 @@ + + +sqlitecpp_dep = dependency( + 'sqlitecpp_dep', + fallback: ['SQLiteCpp', 'sqlitecpp_dep'] +) + +example1_sources = files( + 'main.cpp' +) + +example1_dependencies = [ + dependency('SQLite') +] + +sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo1', + sqlitecpp_sample1_srcs, + dependencies: sqlitecpp_dep, + # override the default options + override_options: sqlitecpp_opts,) \ No newline at end of file diff --git a/examples/example2/meson.build b/examples/example2/meson.build new file mode 100644 index 0000000..7583449 --- /dev/null +++ b/examples/example2/meson.build @@ -0,0 +1,20 @@ + + +sqlitecpp_dep = dependency( + 'sqlitecpp_dep', + fallback: ['SQLiteCpp', 'sqlitecpp_dep'] +) + +example1_sources = files( + 'src/main.cpp' +) + +example1_dependencies = [ + dependency('SQLite') +] + +sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo1', + sqlitecpp_sample1_srcs, + dependencies: sqlitecpp_dep, + # override the default options + override_options: sqlitecpp_opts,) \ No newline at end of file From 2554472a6cf44d87ea4c0a77d87622c963d95219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Fri, 16 Dec 2022 22:44:34 -0600 Subject: [PATCH 2/3] add meson samples --- examples/example1/meson.build | 20 ++++++++++---------- examples/example2/meson.build | 24 +++++++++--------------- examples/meson.build | 2 ++ meson.build | 14 +------------- 4 files changed, 22 insertions(+), 38 deletions(-) create mode 100644 examples/meson.build diff --git a/examples/example1/meson.build b/examples/example1/meson.build index bd4931a..e6dee9e 100644 --- a/examples/example1/meson.build +++ b/examples/example1/meson.build @@ -1,20 +1,20 @@ -sqlitecpp_dep = dependency( - 'sqlitecpp_dep', - fallback: ['SQLiteCpp', 'sqlitecpp_dep'] -) - example1_sources = files( 'main.cpp' ) -example1_dependencies = [ - dependency('SQLite') -] +example1_args = [] + +## under windows define _CRT_SECURE_NO_WARNINGS +if host_machine.system() == 'windows' + example1_args += ['-D_CRT_SECURE_NO_WARNINGS'] +endif + sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo1', sqlitecpp_sample1_srcs, dependencies: sqlitecpp_dep, - # override the default options - override_options: sqlitecpp_opts,) \ No newline at end of file + # inherit the default options from sqlitecpp + override_options: sqlitecpp_opts, + cpp_args: example1_args,) \ No newline at end of file diff --git a/examples/example2/meson.build b/examples/example2/meson.build index 7583449..c6e588f 100644 --- a/examples/example2/meson.build +++ b/examples/example2/meson.build @@ -1,20 +1,14 @@ - - -sqlitecpp_dep = dependency( - 'sqlitecpp_dep', - fallback: ['SQLiteCpp', 'sqlitecpp_dep'] -) - -example1_sources = files( +example2_srcs = files( 'src/main.cpp' ) -example1_dependencies = [ - dependency('SQLite') -] +# if running on windows define _CRT_SECURE_NO_WARNINGS +example2_args = [] -sqlitecpp_demo1_exe = executable('SQLITECPP_sample_demo1', - sqlitecpp_sample1_srcs, + +sqlitecpp_demo2_exe = executable('SQLITECPP_sample_demo1', + sqlitecpp_sample2_srcs, dependencies: sqlitecpp_dep, - # override the default options - override_options: sqlitecpp_opts,) \ No newline at end of file + # inherit the default options from sqlitecpp + override_options: sqlitecpp_opts, + cpp_args: example2_args) \ No newline at end of file diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 0000000..0fc7a16 --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,2 @@ +subdir('example1') +subdir('example2') \ No newline at end of file diff --git a/meson.build b/meson.build index 773b1ef..3edeb59 100644 --- a/meson.build +++ b/meson.build @@ -271,19 +271,7 @@ if get_option('SQLITECPP_BUILD_TESTS') test('sqlitecpp unit tests', testexe, args: test_args) endif if get_option('SQLITECPP_BUILD_EXAMPLES') - ## 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,) - + subdir('examples') endif pkgconfig = import('pkgconfig') From bc8c8ffcc5102ba848a444cc583cc143654098cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Guzm=C3=A1n?= Date: Fri, 16 Dec 2022 22:54:29 -0600 Subject: [PATCH 3/3] add example wrap this wrap file is only for demonstrations purposes once there is a proper wrap in wrapdb this should be deleted if want to use bleeding edge or tag check the meson wrap manual --- subprojects/sqlitecpp.wrap | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 subprojects/sqlitecpp.wrap diff --git a/subprojects/sqlitecpp.wrap b/subprojects/sqlitecpp.wrap new file mode 100644 index 0000000..a7fed59 --- /dev/null +++ b/subprojects/sqlitecpp.wrap @@ -0,0 +1,8 @@ +[wrap-file] +directory = SQLiteCpp-3.2.1 +source_url = https://github.com/SRombauts/SQLiteCpp/archive/refs/tags/3.2.1.zip +source_filename = sqlitecpp-3.2.1.zip +source_hash = 584f7c36b6b169c10c890240ea5fb36318d0ea5713c908f08201a95a93642d21 + +[provide] +sqlitecpp = sqlitecpp_dep