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..e6dee9e --- /dev/null +++ b/examples/example1/meson.build @@ -0,0 +1,20 @@ + + +example1_sources = files( + 'main.cpp' +) + +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, + # 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 new file mode 100644 index 0000000..c6e588f --- /dev/null +++ b/examples/example2/meson.build @@ -0,0 +1,14 @@ +example2_srcs = files( + 'src/main.cpp' +) + +# if running on windows define _CRT_SECURE_NO_WARNINGS +example2_args = [] + + +sqlitecpp_demo2_exe = executable('SQLITECPP_sample_demo1', + sqlitecpp_sample2_srcs, + dependencies: sqlitecpp_dep, + # 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') 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