UTL

Collection of self-contained header-only libraries for C++17

View on GitHub

Building tests & examples

<- back to README.md

This project uses CMake build system with presets as a main way of managing platform-dependent configuration.

All benchmarks, tests and examples are split into granular targets following a similar directory structure, these targets are built as a part of the CI pipeline specified in GitHub workflows.

For tests we use a built-in CMake test runner CTest.

Building with CMake

Clone the repo:

git clone https://github.com/DmitriBogdanov/UTL.git &&
cd "UTL/"

Configure CMake:

cmake --preset gcc

Build the project:

bash "bash/create_single_header.sh" &&
cmake --build --preset gcc

Run tests:

ctest --preset gcc

Run benchmark:

./build/benchmarks/<benchmark_name>

Building with a script

To reduce the tedium of entering verbose commands during development, this repo provides actions.sh script, containing shortcuts for all the actions above set up for gcc preset.

For example, we can clear previous build (if present), configure, build and run tests with a single command:

bash actions.sh clear config build test

Configuring build

Compiler, flags and CTest arguments are specified in CMakePresets.json.

The canonical way of configuring local environment is CMakeUserPresets.json, use existing presets as a reference.

Alternatively, it is possible to override a specific variable from an existing preset, for example, to specify g++13 instead of regular g++ do:

cmake --preset gcc -D CMAKE_CXX_COMPILER="g++13"

Notes on the toolchain

All developer targets are compiled with -Wall -Wextra -Wpedantic -Werror. Tests also use sanitizers provided by the GCC / LLVM toolchain.

CI pipeline is set up to test all 3 major compilers (GCC, clang, MSVC) with different standard libs (libstdc++, libc++, STL) on different operation systems (Ubuntu, MacOS, Windows).

For testing we use doctest framework wrapped in tests/common.hpp.

For benchmarks we use nanobench framework wrapped in benchmarks/common.hpp