Getting Started

How to obtain, build, and start using sharp-runtime in your project.

Prerequisites

ToolRequired VersionNotes
CMake≥ 3.20Build system
C++ compilerC++23 capableGCC 13+, Clang 17+, MSVC 2022 17.5+
ZLIBany modernNeeded only when selecting IO.Compression
GitanyFor submodule initialization

On Debian/Ubuntu, install dependencies:

sudo apt-get install cmake g++ zlib1g-dev

Step 1: Clone with Submodules

sharp-runtime uses git submodules for vendored dependencies (GoogleTest). Always clone with --recurse-submodules:

git clone --recurse-submodules https://github.com/openeggbert/sharp-runtime.git
cd sharp-runtime

If you already cloned without submodules, run:

git submodule update --init --recursive

Step 2: Build

# Configure the complete runtime (the standalone default is also All)
cmake -S . -B build -DSHARP_RUNTIME_COMPONENTS=All

# Build the selected component targets
cmake --build build --parallel 4

Each selected implementation component has its own CMake target and archive. The public aggregate target for the complete runtime is SharpRuntime::All.

Step 3: Run Tests

cmake --build build --target SharpRuntimeTests --parallel 4
scripts/run_component_tests.sh build

The aggregate build target builds the component test executables. The script runs each selected executable and returns a non-zero status if any test fails.

Step 4: Use in Your Project

If your project uses CMake, select the components it uses before adding sharp-runtime as a subdirectory:

# In your CMakeLists.txt
set(SHARP_RUNTIME_COMPONENTS
    Text.Json
    IO.Hashing
)
set(SHARP_RUNTIME_BUILD_TESTS OFF CACHE BOOL "" FORCE)

add_subdirectory(vendor/sharp-runtime)
target_link_libraries(MyApp PRIVATE
    SharpRuntime::Text.Json
    SharpRuntime::IO.Hashing
)

You list direct components only. Their public dependency closure is enabled and linked automatically.

Then include headers:

#include "System/String.hpp"
#include "System/Collections/Generic/List.hpp"
#include "System/Exception.hpp"
#include "SharpRuntime/SharpRuntimeHelper.hpp"

using namespace System;
using SharpRuntime::intcs;

int main() {
    intcs x = 42;
    std::string s = "hello";
    auto parts = String::Split(s + " world", ' ');
    return 0;
}
ℹ Stable include spelling
Public headers are physically owned by their components under modules/*/include/, but consumer include spellings remain unchanged: use paths such as System/String.hpp and SharpRuntime/SharpRuntimeHelper.hpp. The linked SharpRuntime::* target supplies the required include roots.

Build Options

OptionDefaultDescription
SHARP_RUNTIME_COMPONENTSAll for a standalone buildSemicolon-separated component list. Set this explicitly in a parent project.
SHARP_RUNTIME_BUILD_TESTSONBuild test executables for the selected components.
SHARP_RUNTIME_BUILD_BENCHMARKSOFFBuild standalone micro-benchmarks; this enables all components.
# A lean standalone configuration
cmake -S . -B build-json \
  -DSHARP_RUNTIME_BUILD_TESTS=OFF \
  '-DSHARP_RUNTIME_COMPONENTS=Text.Json'
cmake --build build-json --parallel 4

Next Steps