Getting started¶
Everything below is the project's README.md, included as it is, so the two cannot drift apart.
Requirements¶
| Requirement | Version |
|---|---|
| C++ | C++26 (native modules, import std;) |
| CMake | >= 3.30, < 4.4 |
| Compiler | Clang 22 or GCC 16 (with their own standard library build) |
| Generator | Ninja |
| Linker | mold (presets default; override with CMAKE_LINKER_TYPE) |
Note
import std; is still experimental in CMake and gated behind a UUID that changes between CMake releases. cmake/StrataImportStd.cmake maps the CMake version to that UUID; a version outside [3.30, 4.4) may not be covered yet.
Using strata in a project¶
strata is a CMake project exporting one module, strata. import std; must be switched on before your own project(): CMake has to know before it enables C++, which add_subdirectory() is too late to tell it. strata's own mapping of CMake versions to the experimental UUID does it, so fetch strata before project(), without adding it yet, include the mapping, and add it afterwards.
With FetchContent:
cmake_minimum_required(VERSION 3.30)
include(FetchContent)
FetchContent_Declare(
strata
GIT_REPOSITORY https://codeberg.org/Old_est/strata.git
GIT_TAG main # a tag or a commit
SOURCE_SUBDIR cmake # no CMakeLists.txt there: download only
)
FetchContent_MakeAvailable(strata)
include(${strata_SOURCE_DIR}/cmake/StrataImportStd.cmake) # before project()
project(app LANGUAGES CXX)
add_subdirectory(${strata_SOURCE_DIR} strata)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE strata::strata)
With CPM:
cmake_minimum_required(VERSION 3.30)
include(cmake/CPM.cmake)
CPMAddPackage(
NAME strata
GIT_REPOSITORY https://codeberg.org/Old_est/strata.git
GIT_TAG main
DOWNLOAD_ONLY YES
)
include(${strata_SOURCE_DIR}/cmake/StrataImportStd.cmake) # before project()
project(app LANGUAGES CXX)
add_subdirectory(${strata_SOURCE_DIR} strata)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE strata::strata)
A Git submodule works the same way, without the download: include(external/strata/cmake/StrataImportStd.cmake) before project(), add_subdirectory(external/strata) after. Without the include, strata stops the configuration with a message pointing here.
Then import strata; in your sources. Below the top level, strata builds neither its tests nor its examples.
Building¶
or step by step:
Available presets: gcc-debug, gcc-release, clang-debug, clang-release, clang-tidy, gcc-sanitize, clang-sanitize (AddressSanitizer and UndefinedBehaviorSanitizer), gcc-bench and clang-bench (see below).
| Option | Default | Effect |
|---|---|---|
STRATA_BUILD_TESTS | ON when top-level | Builds the tests (fetches boost.ut through CPM). |
STRATA_BUILD_EXAMPLES | ON when top-level | Builds the examples, which CTest runs as smoke tests. |
STRATA_WARNINGS_AS_ERRORS | OFF | Treats compiler warnings as errors. |
STRATA_CLANG_TIDY | OFF | Runs clang-tidy while compiling strata (Clang builds only). |
STRATA_BUILD_BENCHMARKS | OFF | Builds the benchmarks (fetches benchmark and Eigen). |
STRATA_BUILD_DOCS | OFF | Adds the docs target (see Documentation). |
STRATA_SANITIZERS | empty | Sanitizers to build with, e.g. address;undefined. |
The presets keep CPM's source cache in ~/.cache/CPM, shared by every checkout and worktree.