Skip to main content

Add Modelverse to an existing CMake project

Your project already builds; this guide adds the model zoo to it without restructuring anything. The installed directory (Quick install) is the SDK: one find_package, one link target, C++17 or newer.

The integration

find_package(Modelverse CONFIG REQUIRED PATHS "$ENV{MODELVERSE_INSTALL_DIR}/cmake")

target_link_libraries(my_app PRIVATE Modelverse::modelverse)

That wires the public headers, your platform's libclika_modelverse with every model family registered, and the ClikaRT runtime installed in the same root. PATHS keeps the location out of the project files; setting Modelverse_DIR or extending CMAKE_PREFIX_PATH on the configure line works identically, which is the usual shape in CI:

cmake -S . -B build -DModelverse_DIR="$MODELVERSE_INSTALL_DIR/cmake"

Run from your build directory

The libraries live in the install root, and your freshly built binary does not know where that is. modelverse_stage_runtime copies the Modelverse library and the ClikaRT runtime next to the executable, so it runs from the build directory as-is, and the staged layout is exactly what you ship:

modelverse_stage_runtime(TARGET my_app) # beside the binary
modelverse_stage_runtime(TARGET my_app DESTINATION lib) # or a subdirectory

A project already using the runtime keeps its arrangement: if ClikaRT::ClikaRT exists before find_package(Modelverse ...) runs, Modelverse links against it instead of resolving the runtime from the install root. The one constraint is a real pairing: each Modelverse build pins the exact runtime identity it linked against (modelverse.json at the install root), and a mismatched pair refuses at load with a readable error rather than misbehaving later.

Cross builds pick a dist

The package selects the dist (platform/arch flavor) matching your target with the same detection ClikaRT ships, so a cross build that already configures ClikaRT correctly needs nothing extra. When the detection cannot see your intent, name the dist:

cmake -S . -B build-android \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DModelverse_DIR="$MODELVERSE_INSTALL_DIR/cmake" \
-DMODELVERSE_DIST=android-arm64

An install built for a different platform fails at configure time, naming what it carries (dist.json records the platform); the fix is extracting the archive matching your target (Get Modelverse) and pointing the configure at it.

The program to write once the target links is part 4 of the tutorial; for the runtime-only integration story (no model zoo), ClikaRT's own guide on /clikart covers the same ground one layer down.