Build integration¶
This page describes how to integrate Baldr into your own CMake project, including the recommended target settings and platform notes.
Consumer CMakeLists.txt¶
The recommended consumer setup uses FetchContent:
cmake_minimum_required(VERSION 3.28)
project(MyApp VERSION 0.1.0 LANGUAGES CXX)
include(FetchContent)
FetchContent_Declare(
baldr
GIT_REPOSITORY "https://github.com/gilmar-sales/Baldr.git"
GIT_TAG "main" # (1)!
)
FetchContent_MakeAvailable(baldr)
add_executable(my_app src/main.cpp)
target_link_libraries(my_app PRIVATE baldr)
set_target_properties(my_app PROPERTIES
CXX_STANDARD 26
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
- Pin to a specific tag in production code (for example
v0.16.0).
Targets exposed¶
Baldr defines a single library target, baldr, with the alias baldr::baldr. Both names link to the same library.
target_link_libraries(my_app PRIVATE baldr) # works
target_link_libraries(my_app PRIVATE baldr::baldr) # also works
The target sets CXX_STANDARD 26 internally. When you link against baldr, you should set your own consumer target to C++26 as well.
Compile features¶
The following compile features are required:
- C++26 — for concepts,
<format>, designated initializers,simdjson, andstd::meta::inforeflection (used by the OpenAPI extension to auto-derive JSON Schemas from return types viasrc/Baldr/OpenApi/JsonSchemaEmitter.cpp). - A compiler with C++26 reflection support is required to build Baldr from source. CI installs
gcc-16on Linux; Clang 17+ with libstdc++ 14+ works in principle, but Clang is not part of the matrix (it does not implement P2996 reflection); MSVC 19.40+ works in principle but is also not part of the matrix.
Transitive dependencies¶
FetchContent_MakeAvailable(baldr) also fetches:
You don't need to declare these yourself — Baldr links them in and propagates their include directories to consumers.
In addition, CompressionMiddleware requires zlib. Baldr calls find_package(ZLIB QUIET) and aborts with a FATAL_ERROR if it is missing, so install the development package on your platform (see Get started).
Platform notes¶
Linux¶
- GCC 16+ recommended (CI uses
gcc-16; Clang and MSVC are not part of the matrix because they don't yet implement C++26 reflection). - Install
zlib1g-dev(Debian/Ubuntu) orzlib-devel(Fedora/RHEL) for the compression middleware.
macOS¶
- Apple Clang 17+ (Xcode 16) or the official LLVM Clang 17+.
- No additional system packages are required (zlib ships with the platform SDK).
Windows¶
- MSVC 19.40+ (Visual Studio 2022 17.10+) or the latest MSVC Build Tools.
- zlib is provided by vcpkg or the platform — install
zlibvia vcpkg or use the version that ships with the Windows SDK. - Use
cmake -S . -B buildfrom a Developer Command Prompt for VS or a normal shell ifcl.exeis onPATH.
Disabling examples and tests¶
When Baldr is the top-level project (add_subdirectory(baldr)), it builds examples and tests by default. Through FetchContent these options are forced off, so you don't need to do anything.
If you add Baldr as a subdirectory directly, you can opt out:
set(BALDR_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BALDR_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(baldr)