Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meson usage guide #395

Merged
merged 3 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions examples/example1/meson.build
Original file line number Diff line number Diff line change
@@ -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,)
14 changes: 14 additions & 0 deletions examples/example2/meson.build
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subdir('example1')
subdir('example2')
14 changes: 1 addition & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions subprojects/sqlitecpp.wrap
Original file line number Diff line number Diff line change
@@ -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