Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Using Rito

Bartłomiej Jaszczak edited this page Nov 5, 2023 · 2 revisions

Linux

Use installed Rito (recommended)

The easiest way is to build and install Rito (either globally, in your system, or locally). Then, in CMakeLists.txt of your project, add somewhere:

find_package(Rito REQUIRED)

and also link it to your application:

target_link_libraries(YourAppTargetName PRIVATE Rito::Rito)
  • If Rito was installed globally, just build your project and it should work.
$ cd YourProjectDir
$ cmake -S . -B build
$ cmake --build build
  • If you installed Rito locally (and therefore it's not visible in the system globally), you'll need to specify path to Rito installation. You can either make sure that CMAKE_PREFIX_PATH points to where you installed Rito:
$ cd YourProjectDir
$ cmake -S . -B build -DCMAKE_PREFIX_PATH=<path_to_rito_installation_dir>
$ cmake --build build

or set Rito_DIR to the exact directory which contains RitoConfig.cmake file:

$ cd YourProjectDir
$ cmake -S . -B build -DRito_DIR=<path_to_rito_installation_dir>/lib/cmake/rito
$ cmake --build build

Remember that Rito depends on POCO - if POCO is not installed globally you'll also need to specify where it is installed!

Add Rito as subdirectory

Another way is to add Rito as subdirectory to your cmake project. Either copy Rito project directory into your project or embed it as git submodule. Then, in your CMakeLists.txt, add:

add_subdirectory(<rito_directory>)

and also link it to your application:

target_link_libraries(YourAppTargetName PRIVATE Rito::Rito)

Windows

Add Rito as subdirectory (in cmake project) (recommended)

On Windows, easiest way to use Rito is to embed it in your application. You can either do it via git submodules or you can just copy rito directory into your project. Then, in CMakeLists.txt of your project add:

add_subdirectory(<rito_directory>)

and also link it to your application:

target_link_libraries(YourAppTargetName PRIVATE Rito::Rito)

It should be noted that Rito depends on POCO and POCO libraries have to be present at build time. Easiest way is to use embedded vcpkg to get it by following this instruction and set CMAKE_TOOLCHAIN_FILE during build of your project:

> cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=<rito_directory>\tools\vcpkg\scripts\buildsystems\vcpkg.cmake"

Windows executables have to "see" all the DLLs required for the application to run (including Rito DLL, as well as POCO DLLs). For convenience, adding this line at the beginning of your CMakeLists.txt will cause cmake to copy all required DLLs to the build directory of your project:

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

Use installed Rito (in cmake project)

If you built and installed Rito, you can use it in your cmake project by adding this to your CMakeLists.txt file:

find_package(Rito REQUIRED)

and also linking your project to Rito:

target_link_libraries(YourAppTargetName PRIVATE Rito::Rito)

Resolving dependencies

Rito

Now, if you installed Rito globally, cmake should automatically find its path. Otherwise, you'll need to specify where to find RitoConfig.cmake file via Rito_DIR:

> cmake -S . -B build "-DRito_DIR=<path_to_rito_installation_dir>\lib\cmake\rito"

or provide Rito installation path via CMAKE_PREFIX_PATH:

> cmake -S . -B build "-DCMAKE_PREFIX_PATH=<path_to_rito_installation_dir>"

POCO

The same applies to POCO, which is dependency of Rito. If you built and installed POCO via vcpkg, you'll need to either provide direct path to POCO installation (via Poco_DIR or CMAKE_PREFIX_PATH) or set CMAKE_TOOLCHAIN_FILE to file provided with vcpkg. Last option is the easiest one as this is how you've got POCO in the first place:

> cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=<path_to_vcpkg>\scripts\buildsystems\vcpkg.cmake"

Building your project

Combining both dependencies, you might build your project like this:

> cd YourProjectDir
> cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=<path_to_vcpkg>\scripts\buildsystems\vcpkg.cmake" "-DCMAKE_PREFIX_PATH=<path_to_rito_installation_dir>"
> cmake --build build --config Release