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
| Target | Type | Description |
|---|---|---|
SharpRuntime::Core.Base | Static component | Foundation types and the base dependency for most components. |
SharpRuntime::Text.Json | Static component | JSON support with only its required dependency closure. |
SharpRuntime::IO.Compression | Static component | Compression support; configures ZLIB only when selected. |
SharpRuntime::All | Interface aggregate | Complete runtime surface and all physical components. |
SHARP_RUNTIME | Compatibility aggregate | For existing consumers; available only when All is selected. |
SharpRuntimeTests | Custom build target | Builds all test executables for the requested components. |
SharpRuntimeTests_<Component> | Executable | Component-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
| Library | Location | How Included |
|---|---|---|
| GoogleTest | vendor/googletest/ | Git submodule; required only when tests are enabled |
| nlohmann/json | vendor/nlohmann/json.hpp | Header-only, no CMake target needed |
| tinyxml2 | vendor/tinyxml2/ | Configured by Xml; public because XML headers expose its types |
| miniz | vendor/miniz/ | Configured privately by IO.Compression.Zip |
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
| Problem | Cause | Fix |
|---|---|---|
| Could not find ZLIB | IO.Compression was selected but ZLIB is not installed | Install zlib1g-dev (Linux) or zlib (Homebrew) |
| vendor/googletest missing | Submodule not initialized | git submodule update --init --recursive |
| C++23 errors | Old compiler | Update to GCC 13+, Clang 17+, or MSVC 2022 17.5+ |
| POSIX headers missing on Windows | POSIX-only code in .cpp | Known limitation; Windows platform guards are a known gap |