Skip to main content

Building

Build ccompose on Linux, macOS, or Windows, or add it as a dependency of your project. For browser builds, see Web (WASM). For build errors, see Troubleshooting.

Requirements​

  • CMake 3.23 or later.
  • A C compiler with C11 support. GCC, Clang and MSVC all work. C17 and C23 are also supported via -DCCOMPOSE_C_STANDARD=17 or 23.
  • raylib 5.5 (optional). If raylib is already installed through your package manager or vcpkg, CMake uses it. Otherwise ccompose downloads and builds it with FetchContent.

Linux​

cmake -S . -B build
cmake --build build

When CMake can't find an installed raylib, it fetches raylib 5.5 from GitHub and builds it. That source build needs the X11 and GL development headers:

# Debian / Ubuntu
sudo apt install libgl1-mesa-dev libx11-dev libxrandr-dev \
libxinerama-dev libxcursor-dev libxi-dev

# Fedora
sudo dnf install mesa-libGL-devel libX11-devel libXrandr-devel \
libXinerama-devel libXcursor-devel libXi-devel

A distro package skips the source fetch and makes configuring faster:

sudo apt install libraylib-dev # Debian / Ubuntu, where packaged

macOS​

cmake -S . -B build
cmake --build build

Xcode Command Line Tools (xcode-select --install) supply Clang and the SDK headers. No other packages are required. To use a system raylib instead of the fetched one, run brew install raylib first.

Apple Silicon and Intel are both supported. For a universal binary:

cmake -S . -B build -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
cmake --build build

Windows​

To use raylib from vcpkg:

vcpkg install raylib:x64-windows

cmake -S . -B build ^
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake ^
-DVCPKG_TARGET_TRIPLET=x64-windows
cmake --build build --config Debug

Without vcpkg, CMake fetches and builds raylib 5.5 itself. MSVC alone is enough, no extra system packages.

Visual Studio generators are multi-config, so outputs land in a per-config folder such as build/examples/Debug/.

Cross-compiling from Linux to Windows​

The repo ships a MinGW-w64 toolchain file at cmake/mingw-w64-x86_64.cmake:

# Arch: sudo pacman -S mingw-w64-gcc
# Debian / Ubuntu: sudo apt install mingw-w64

cmake -S . -B build-win \
-DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w64-x86_64.cmake \
-DCMAKE_BUILD_TYPE=Release
cmake --build build-win -j

The resulting .exe files run under Wine for smoke testing.

Headless build​

Disable raylib for CI, unit tests, or machines without a display:

cmake -S . -B build -DCCOMPOSE_BACKEND_RAYLIB=OFF
cmake --build build

This defines CCOMPOSE_NO_BACKEND for consumers of the target and doesn't build the demo. Raylib-typed APIs (CC_LoadImage, Image, Texture2D, Font) are not declared in this mode. See Headless mode for what changes at runtime.

Running the demo and tests​

./build/examples/ccompose_demo # Linux / macOS
./build/examples/Debug/ccompose_demo.exe # Windows, multi-config

ctest --test-dir build --output-on-failure # headless smoke tests

CMake options​

OptionDefaultEffect
CCOMPOSE_BACKEND_RAYLIBONBuild the bundled raylib backend. Turn off for headless builds.
CCOMPOSE_BUILD_EXAMPLESON when top-levelBuild the example programs.
CCOMPOSE_BUILD_TESTSON when top-levelBuild the tests and register them with CTest.
CCOMPOSE_WARNINGS_AS_ERRORSOFFPromote warnings in ccompose's own source to errors (-Werror or /WX). Vendored Clay and the raylib renderer build with -w and are unaffected.
CCOMPOSE_INSTALLON when top-level and not cross-compilingGenerate install rules and a CMake package config so consumers can find_package(ccompose). Forced off under Emscripten and cross-compiling.
CCOMPOSE_TARGET_WEBON under the Emscripten toolchainBuild for the browser. See Web (WASM).
CCOMPOSE_C_STANDARD11Language standard: 11, 17 or 23.
CCOMPOSE_RAYLIB_VERSION5.5raylib tag to fetch from raysan5/raylib when find_package(raylib) fails.

Using ccompose in your project​

As a subdirectory:

add_subdirectory(third_party/ccompose)
target_link_libraries(my_app PRIVATE ccompose::ccompose)

From an install (cmake --install build):

find_package(ccompose REQUIRED)
target_link_libraries(my_app PRIVATE ccompose::ccompose)

Linking the target brings in the include paths, raylib (when the backend is on) and the CCOMPOSE_NO_BACKEND define (when it is off).

Formatting your own code​

To put each designated initializer on its own line, use this .clang-format configuration:

BasedOnStyle: InheritParentConfig
AlignAfterOpenBracket: BlockIndent
BinPackArguments: false