Build System

CMake configuration, compiler requirements, build commands, and platform notes.

Build System: CMake

sharp-runtime uses CMake ≥ 3.20 as its build system. It exposes 40 physical components with narrow public dependency closures. A standalone build selects All by default; parent projects should choose the components they use.

CMakeLists.txt

C++ Standard

The project requires C++23:

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Use GCC 13+, Clang 17+, or MSVC 2022 17.5+ (or later).

Component Ownership

Every physical component owns its public headers, implementation sources, tests, and CMake declaration under one directory:

modules/<module>/
├── CMakeLists.txt
├── include/       # Public headers for this component
├── src/           # Implementation sources (when needed)
└── tests/         # GoogleTest sources for this component

Components are registered explicitly. Their declarations state public, private, and test-only dependencies, and the build validates that source files have one owner and that dependencies have the right visibility.

Targets

TargetTypeDescription
SharpRuntime::Core.BaseStatic componentFoundation types and the base dependency for most components.
SharpRuntime::Text.JsonStatic componentJSON support with only its required dependency closure.
SharpRuntime::IO.CompressionStatic componentCompression support; configures ZLIB only when selected.
SharpRuntime::AllInterface aggregateComplete runtime surface and all physical components.
SHARP_RUNTIMECompatibility aggregateFor existing consumers; available only when All is selected.
SharpRuntimeTestsCustom build targetBuilds all test executables for the requested components.
SharpRuntimeTests_<Component>ExecutableComponent-scoped GoogleTest executable, for example SharpRuntimeTests_Text_Json.

Build Commands

Standard Build

cmake -S . -B build -DSHARP_RUNTIME_COMPONENTS=All
cmake --build build --parallel 4

Release Build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSHARP_RUNTIME_COMPONENTS=All
cmake --build build --parallel 4

Lean Component Build

cmake -S . -B build-json \
  -DSHARP_RUNTIME_BUILD_TESTS=OFF \
  '-DSHARP_RUNTIME_COMPONENTS=Text.Json'
cmake --build build-json --parallel 4

The requested component enables its dependency closure automatically. New consumers should link direct targets such as SharpRuntime::Text.Json, not an aggregate target.

Without Tests

cmake -S . -B build -DSHARP_RUNTIME_BUILD_TESTS=OFF
cmake --build build --parallel 4

Errors and Warnings Only

cmake --build build --parallel 4 2>&1 | grep -E "error:|warning:" | grep -v "^#"

Compiler Flags

The library enables strict warnings and treats warnings as errors:

# GCC / Clang
-Wall -Wextra -Werror -Wno-format-truncation

# MSVC
/W4 /WX

The rule "zero errors, zero warnings" is a project invariant — no commit should break this.

External Dependencies

ZLIB (IO.Compression only)

ZLIB is found with find_package(ZLIB REQUIRED) only when IO.Compression is selected. A text-, collections-, or JSON-only build does not configure it.

# Debian/Ubuntu
sudo apt-get install zlib1g-dev

# macOS
brew install zlib

Vendored Libraries

LibraryLocationHow Included
GoogleTestvendor/googletest/Git submodule; required only when tests are enabled
nlohmann/jsonvendor/nlohmann/json.hppHeader-only, no CMake target needed
tinyxml2vendor/tinyxml2/Configured by Xml; public because XML headers expose its types
minizvendor/miniz/Configured privately by IO.Compression.Zip
⚠ Missing submodule
If vendor/googletest/CMakeLists.txt is missing, CMake will emit a fatal error:
Run: git submodule update --init --recursive

Platform-Specific Notes

Windows

The Net component links ws2_32 privately on Windows. The random-cryptography component similarly owns its private bcrypt dependency; neither leaks into unrelated builds.

Some subsystems use POSIX APIs and currently only compile on Linux/macOS. These are documented as POSIX-only bugs in CLAUDE.md.

Android

On Android, the Storage component uses SDL3 paths. If storage is selected, the parent project must create either SDL3::SDL3 or SDL3::SDL3-static before adding sharp-runtime. The linkage is private to that component.

Emscripten

Emscripten builds compile cleanly. Features that are unavailable at runtime throw System::PlatformNotSupportedException.

Common Build Problems

ProblemCauseFix
Could not find ZLIBIO.Compression was selected but ZLIB is not installedInstall zlib1g-dev (Linux) or zlib (Homebrew)
vendor/googletest missingSubmodule not initializedgit submodule update --init --recursive
C++23 errorsOld compilerUpdate to GCC 13+, Clang 17+, or MSVC 2022 17.5+
POSIX headers missing on WindowsPOSIX-only code in .cppKnown limitation; Windows platform guards are a known gap