Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

87.8. fmt-12.2.0

The C++ formatting library std::format was standardised from

Version 12.2.0, release 1
Shelf devlibs — General-purpose C and C++ utility libraries with no domain
Phase 41_system (System), 273 of 1047 in build order
Licence MIT
Homepage https://fmt.dev/
Build time 0.4 SBU
Installed size 786.5 KiB in 25 files
Recipe ports/core/devlibs/fmt/kpkgbuild

About

{fmt} is a C++ text-formatting library and an implementation of C++20’s std::format: type-safe fmt::format("{}", x) and fmt::print with Python-style replacement fields, plus formatters for chrono types, ranges, colours and the rest of the standard library. Many ports link it, among them spdlog, which this tree builds against it with SPDLOG_FMT_EXTERNAL=ON rather than with the copy spdlog carries, mpd, mkvtoolnix and blender. They find it through fmt-config.cmake or fmt.pc, both of which this package installs.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/devlibs.txt:

mpd reaches for an fmt SUBPROJECT WRAP when the system one is absent, which is a download in a build that has no network.

Sources

Dependencies

Depends on: cmake.

Required by (22): android-tools, blender, celestia, coeurl, coolprop, curaengine, freecad, furnace, gnuradio, goldendict-ng, imhex, libvolk, mkvtoolnix, mpd, mtxclient, nheko, openimageio, python3-pyuvula, rawtherapee, spdlog, supertux, vte3.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install fmt'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devlibs/fmt.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/devlibs/fmt
echo '8b852bb5aa6e7d8564f9e81394055395dd1d1936d38dfd3a17792a02bebd7af0  fmt-12.2.0.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/fmt
SRC=$SRC_ROOT/fmt-12.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf fmt-12.2.0.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -p build && cd build
cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib \
	-DBUILD_SHARED_LIBS=ON -DFMT_TEST=OFF -DFMT_DOC=OFF
make
make DESTDIR=$PKG install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/fmt, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf fmt-12.2.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/fmt, and runs the triggers its paths call for.

Contents

Installed libraries: libfmt-c.a, libfmt.so.

Installed directories: /usr/include/fmt, /usr/lib/cmake/fmt, /usr/share/licenses/fmt.

Short descriptions

fmt.pc A modern formatting library