Building libbase

Prerequisites

Attention

Ensure you have all prerequisites installed and configured. See Prerequisites for more details.

Obtaining the source code

The recommended way to obtain the source code is:

$ git clone https://github.com/RippeR37/libbase.git

You can pass an additional --depth <depth> argument to limit the repository history to be downloaded (e.g. --depth 1).

Resolving libbase dependencies

To build libbase you need to either build and install required dependencies manually or configure a package manager like vcpkg to resolve them automatically.

Building with CMake and pre-installed dependencies

Assuming all required dependencies are already installed on your system, you can build libbase with CMake simply by running:

$ cmake -S . -B build
$ cmake --build build [-j <parallel_jobs>] [--config <Release|Debug>]

This will configure libbase with the default configuration options and build it in the build/ subdirectory.

Building with CMake and vcpkg

If you don’t have the required dependencies installed on your system, the recommended and simplest way to build libbase is to use the vcpkg package manager.

If you already have vcpkg installed and want to use it to resolve the dependencies, you can do so by running the following commands:

$ export VCPKG_ROOT=/path/to/vcpkg
$ cmake -S . -B build
$ cmake --build build [-j <parallel_jobs>] [--config <Release|Debug>]

or

$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
$ cmake --build build [-j <parallel_jobs>] [--config <Release|Debug>]

Alternatively, if you don’t have (or don’t want to use) pre-existing vcpkg installation you can ask libbase to set up its own internal vcpkg installation just for task of building itself with:

$ cmake -S . -B build -DLIBBASE_AUTO_VCPKG=1
$ cmake --build build [-j <parallel_jobs>] [--config <Release|Debug>]

Building with CMake and Conan

Alternatively, you can also use Conan package manager to build libbase library. To do this, you need to have Conan installed on your system, then simply execute:

$ conan install . --build=missing -s build_type=Release [-o '&:option=value']
$ cmake --preset conan-release
$ cmake --build --preset conan-release [-j <parallel_jobs>]

See options and default_options attributes in conanfile.py for available build options.

Configuration

You can configure libbase build or library itself by overriding default options defined in CMake scripts. You can do this by specifying the -DOPTION_NAME=[ON/OFF] switch for a given option during CMake configuration phase. For example, to build libbase with the documentation, you would have to execute:

$ cmake -S . -B build -DLIBBASE_BUILD_DOCS=ON
$ cmake --build build

See also

Check out the Configuration options page to see available options and their description.

Running the tests

If you’ve built the library with unit tests (see Configuration options), you can run them all with:

$ ctest --test-dir build