Build a First Consumer
Create a minimal CMake application that links only SharpRuntime::Console.
Goal
Build a tiny native executable using one physical component. This keeps the dependency graph visible and avoids pulling the complete runtime into an embedding project.
1. Create the files
cmake_minimum_required(VERSION 3.20)
project(hello_sharp_runtime LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SHARP_RUNTIME_COMPONENTS Console)
set(SHARP_RUNTIME_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(sharp-runtime)
add_executable(hello main.cpp)
target_link_libraries(hello PRIVATE SharpRuntime::Console)#include <System/Console.hpp>
int main()
{
System::Console::WriteLine("Hello from native C++23.");
return 0;
}
2. Add the source checkout
Clone Sharp Runtime as sharp-runtime/ beneath the sample project. GoogleTest is unnecessary because this consumer forces runtime tests off.
git clone https://github.com/openeggbert/sharp-runtime.git sharp-runtime
3. Configure, build and run
cmake -S . -B build
cmake --build build --parallel 2
./build/hello
What happened
SHARP_RUNTIME_COMPONENTSwas set before adding the subdirectory.- The app linked the namespaced physical target
SharpRuntime::Console. - CMake automatically enabled
Core.Base, Console’s public dependency. - The executable is native C++; no CLR or managed assembly is involved.
Verified shape
The include, namespace, method, CMake option and target names are present at the pinned source SHA.