---
title: Add Modelverse to an existing CMake project
description: find_package against the installed directory, staging the runtime beside your binary, and picking the dist on cross builds.
---

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

## The integration

```cmake
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:

```bash
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:

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

## When you already link ClikaRT

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 is built against the runtime of its own release, and a mismatched pair refuses at load with a readable error naming both versions 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:

```bash
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](../getting-started/get-modelverse.md)) and pointing the configure at it.

The program to write once the target links is [part 4 of the tutorial](../getting-started/first-model/04-use-it-from-code.mdx); for the runtime-only integration story (no model zoo), ClikaRT's own guide on [/clikart](/clikart) covers the same ground one layer down.
