CMake Integration and Installation
The Xronos C++ SDK can be integrated into your CMake project via
FetchContent,
installed system-wide, or used via a pre-built Docker base image. In all cases,
link your targets against xronos::xronos-sdk.
FetchContent
Binary Artifacts (Recommended)
FetchContent will download pre-built binary artifacts for your platform and integrate them with your build.
cmake_minimum_required(VERSION 3.28)
project(<your-project> LANGUAGES CXX)
set(XRONOS_SDK_VERSION "0.11.2" CACHE STRING "Xronos SDK version")
include(FetchContent)
FetchContent_Declare(
"xronos-sdk"
URL https://github.com/xronos-inc/xronos/releases/download/v${XRONOS_SDK_VERSION}/xronos-sdk-${XRONOS_SDK_VERSION}-Linux-${CMAKE_SYSTEM_PROCESSOR}.tar.gz
)
FetchContent_MakeAvailable(xronos-sdk)
set(xronos-sdk_DIR ${xronos-sdk_SOURCE_DIR}/share/cmake/xronos-sdk)
find_package(xronos-sdk ${XRONOS_SDK_VERSION} EXACT)
add_executable(<your-target> <your-source>.cc)
target_link_libraries(<your-target> xronos::xronos-sdk)
From Source
Note that building the SDK from source can take a while — we recommend using the pre-built binary artifacts when possible.
cmake_minimum_required(VERSION 3.28)
project(<your-project> LANGUAGES CXX)
set(XRONOS_SDK_VERSION "0.11.2" CACHE STRING "Xronos SDK version")
include(FetchContent)
FetchContent_Declare(
"xronos-sdk"
GIT_REPOSITORY https://github.com/xronos-inc/xronos
GIT_TAG v${XRONOS_SDK_VERSION}
SOURCE_SUBDIR cpp-sdk
)
FetchContent_MakeAvailable(xronos-sdk)
add_executable(<your-target> <your-source>.cc)
target_link_libraries(<your-target> xronos::xronos-sdk)
System-Wide Installation
As an alternative to FetchContent, the SDK can be installed system-wide.
Once installed, use the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.28)
project(<your-project> LANGUAGES CXX)
set(XRONOS_SDK_VERSION "0.11.2" CACHE STRING "Xronos SDK version")
find_package(xronos-sdk ${XRONOS_SDK_VERSION} EXACT)
add_executable(<your-target> <your-source>.cc)
target_link_libraries(<your-target> xronos::xronos-sdk)
.deb Package
For Ubuntu 22.04 or newer, download the .deb package for your architecture from the release page and install it with:
$ sudo dpkg -i <path-to-your-deb-file>
Binary Artifacts
Download the .tar.gz archive from the release
page and extract it in
the system root or a directory of your choice:
$ tar -xf <path-to-your-tar-file> -C <xronos-install-location>
If you install to a location other than /, pass
-DCMAKE_INSTALL_PREFIX=<xronos-install-location> when invoking CMake.
Docker Base Image
The xronosinc/xronos image is a
Debian-based image with the Xronos C++ SDK, Python SDK, and CMake pre-installed.
Use it as a base for your Dockerfile to avoid managing SDK installation yourself.
The SDK is available system-wide, so the same CMakeLists.txt as in
System-Wide Installation applies.
FROM xronosinc/xronos:0.11.2 AS base
WORKDIR /workspace
COPY CMakeLists.txt .
COPY src/ src/
RUN cmake -B build && cmake --build build