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

TargetTypeDescription
SHARP_RUNTIMESTATIC libraryMain library. Output: libSHARP_RUNTIME.a
tinyxml2STATIC libraryVendored XML library
minizSTATIC libraryVendored ZIP/deflate library
SharpRuntimeTestsExecutableGoogleTest 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

LibraryLocationHow Included
GoogleTestvendor/googletest/git submodule; added via add_subdirectory
nlohmann/jsonvendor/nlohmann/json.hppHeader-only, no CMake target needed
tinyxml2vendor/tinyxml2/Compiled as tinyxml2 static library target
minizvendor/miniz/Compiled as miniz static library target
⚠ 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 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

ProblemCauseFix
Could not find ZLIBZLIB 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