Getting Started
How to obtain, build, and start using sharp-runtime in your project.
Prerequisites
| Tool | Required Version | Notes |
|---|---|---|
| CMake | ≥ 3.20 | Build system |
| C++ compiler | C++23 capable | GCC 13+, Clang 17+, MSVC 2022 17.5+ |
| ZLIB | any modern | Needed only when selecting IO.Compression |
| Git | any | For 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;
}
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
| Option | Default | Description |
|---|---|---|
SHARP_RUNTIME_COMPONENTS | All for a standalone build | Semicolon-separated component list. Set this explicitly in a parent project. |
SHARP_RUNTIME_BUILD_TESTS | ON | Build test executables for the selected components. |
SHARP_RUNTIME_BUILD_BENCHMARKS | OFF | Build 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