Skip to content

[ Getting started ]

Installation and CMake Integration

CMakeLists.txt defines the static library target koto and the alias target koto::koto (CMakeLists.txt:15, 39) with PUBLIC compile feature cxx_std_23 (CMakeLists.txt:46).

CMake OptionDefaultDescription
KOTO_BUILD_TESTSONBuilds all test executables in tests/*.cpp and registers 6 CTest suites.
KOTO_BUILD_EXAMPLESONBuilds the kotoapp executable from test/main.cpp.
KOTO_ENABLE_WERROROFFAppends -Werror to koto’s private compile options.
cmake_minimum_required(VERSION 3.15)
project(my_koto_app LANGUAGES CXX)
include(FetchContent)
FetchContent_Declare(
koto
GIT_REPOSITORY https://github.com/saber-88/koto.git
GIT_TAG main
)
set(KOTO_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(KOTO_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(koto)
add_executable(my_koto_app src/main.cpp)
target_link_libraries(my_koto_app PRIVATE koto::koto)

Option 2: Vendored subdirectory (add_subdirectory)

Section titled “Option 2: Vendored subdirectory (add_subdirectory)”

Clone or add koto as a Git submodule and include it with add_subdirectory:

Terminal window
git submodule add https://github.com/saber-88/koto.git external/koto
cmake_minimum_required(VERSION 3.15)
project(my_koto_app LANGUAGES CXX)
set(KOTO_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(KOTO_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(external/koto)
add_executable(my_koto_app src/main.cpp)
target_link_libraries(my_koto_app PRIVATE koto::koto)

Because koto exports target_compile_features(koto PUBLIC cxx_std_23) and the Clang < 19.0 __cpp_concepts=202002L workaround as PUBLIC (CMakeLists.txt:46-53), linking against koto::koto propagates both the include directory and the C++23 requirement to my_koto_app.

Option 3: System installation (find_package and pkg-config)

Section titled “Option 3: System installation (find_package and pkg-config)”

CMakeLists.txt:70-117 installs the library, headers (include/koto), CMake package config files (kotoTargets.cmake, kotoConfig.cmake, kotoConfigVersion.cmake under ${CMAKE_INSTALL_LIBDIR}/cmake/koto), and koto.pc under ${CMAKE_INSTALL_LIBDIR}/pkgconfig:

Terminal window
cmake -B build -DCMAKE_BUILD_TYPE=Release -DKOTO_BUILD_TESTS=OFF -DKOTO_BUILD_EXAMPLES=OFF
cmake --build build --parallel
sudo cmake --install build

Consumer CMakeLists.txt using find_package:

cmake_minimum_required(VERSION 3.15)
project(my_koto_app LANGUAGES CXX)
find_package(koto 1.0.0 REQUIRED)
add_executable(my_koto_app src/main.cpp)
target_link_libraries(my_koto_app PRIVATE koto::koto)

Or via pkg-config (cmake/koto.pc.in:1-10):

Terminal window
g++ -std=c++23 main.cpp $(pkg-config --cflags --libs koto) -o my_koto_app