Build System
CMake configuration, compiler requirements, build commands, and platform notes.
Build System: CMake
sharp-runtime uses CMake ≥ 3.20 as its build system. The root CMakeLists.txt configures a single static library target SHARP_RUNTIME and an optional test executable SharpRuntimeTests.
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).
Source Discovery
CMake uses GLOB_RECURSE to auto-discover all .cpp files under src/. No manual source registration is needed when adding new implementation files:
file(GLOB_RECURSE SHARP_RUNTIME_SOURCES CONFIGURE_DEPENDS
"src/*.cpp"
)
Targets
| Target | Type | Description |
|---|---|---|
SHARP_RUNTIME | STATIC library | Main library. Output: libSHARP_RUNTIME.a |
tinyxml2 | STATIC library | Vendored XML library |
miniz | STATIC library | Vendored ZIP/deflate library |
SharpRuntimeTests | Executable | GoogleTest test runner (optional) |
Build Commands
Standard Build
cmake -S . -B build
cmake --build build --parallel 4
Release Build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel 4
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 (Required)
ZLIB must be installed on the system. CMake finds it via find_package(ZLIB REQUIRED).
# Debian/Ubuntu
sudo apt-get install zlib1g-dev
# macOS
brew install zlib
Vendored Libraries
| Library | Location | How Included |
|---|---|---|
| GoogleTest | vendor/googletest/ | git submodule; added via add_subdirectory |
| nlohmann/json | vendor/nlohmann/json.hpp | Header-only, no CMake target needed |
| tinyxml2 | vendor/tinyxml2/ | Compiled as tinyxml2 static library target |
| miniz | vendor/miniz/ | Compiled as miniz static library target |
vendor/googletest/CMakeLists.txt is missing, CMake will emit a fatal error:
Run: git submodule update --init --recursive
Platform-Specific Notes
Windows
The Windows Sockets library is linked automatically:
if(WIN32)
target_link_libraries(SHARP_RUNTIME PRIVATE ws2_32)
endif()
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, StoragePaths.cpp uses SDL3 paths. SDL3 must be provided by the parent project (CNA) before this subdirectory is added:
if(ANDROID AND TARGET SDL3::SDL3)
target_link_libraries(SHARP_RUNTIME PRIVATE SDL3::SDL3)
elseif(ANDROID AND TARGET SDL3::SDL3-static)
target_link_libraries(SHARP_RUNTIME PRIVATE SDL3::SDL3-static)
endif()
Emscripten
Emscripten builds compile cleanly. Features that are unavailable at runtime throw System::PlatformNotSupportedException.
Common Build Problems
| Problem | Cause | Fix |
|---|---|---|
| Could not find ZLIB | ZLIB 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 |