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 | System library; install via package manager |
| 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
cmake -S . -B build
# Build (parallel)
cmake --build build --parallel 4
The output is a static library: build/libSHARP_RUNTIME.a (Linux/macOS) or build/SHARP_RUNTIME.lib (Windows).
Step 3: Run Tests
./build/SharpRuntimeTests
Expect output similar to:
[==========] 3132 tests from 471 test suites ran.
[ PASSED ] 3132 tests.
Step 4: Use in Your Project
If your project uses CMake, add sharp-runtime as a subdirectory:
# In your CMakeLists.txt
add_subdirectory(vendor/sharp-runtime)
target_link_libraries(MyApp PRIVATE SHARP_RUNTIME)
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;
}
ℹ Include path
All public headers live under include/. The CMake target
SHARP_RUNTIME adds this directory to include paths automatically
via target_include_directories(SHARP_RUNTIME PUBLIC …).
Build Options
| Option | Default | Description |
|---|---|---|
SHARP_RUNTIME_BUILD_TESTS | ON | Build the test executable. Set to OFF to skip GoogleTest. |
# Disable tests (e.g., when embedding in another project)
cmake -S . -B build -DSHARP_RUNTIME_BUILD_TESTS=OFF