Harmont docs
Examples

CMake (C / C++)

A CMake project wired to Harmont — configure, build, test, and format.

Harmont has first-class CMake support. One hm.cmake(...) call picks the compiler, passes cache defines, and gives you test(), lint(), and fmt() actions backed by CTest and clang-format. This example uses an explicit compiler and a Release build with C++20.

Project layout

CMakeLists.txt

Pipeline

.hm/pipeline.py
"""Advanced CMake pipeline — compiler selection, multiple actions."""from __future__ import annotationsimport harmont as hm@hm.pipeline(    "ci",    env={"CI": "true"},    default_image="ubuntu:24.04",    triggers=[hm.push(branch="main"), hm.pr()],)def ci() -> tuple[hm.Step, ...]:    project = hm.cmake(        path=".",        compiler="clang-18",        defines={            "CMAKE_BUILD_TYPE": "Release",            "CMAKE_CXX_STANDARD": "20",            "BUILD_TESTING": "ON",        },    )    return (        project.test(),        project.lint(),        project.fmt(),    )
.hm/pipeline.ts
import { pipeline, push, pullRequest, type PipelineDefinition } from "@harmont/hm";import { cmake } from "@harmont/hm/toolchains";const project = cmake({  path: ".",  compiler: "clang-18",  defines: {    CMAKE_BUILD_TYPE: "Release",    CMAKE_CXX_STANDARD: "20",    BUILD_TESTING: "ON",  },});const pipelines: PipelineDefinition[] = [  {    slug: "ci",    triggers: [push({ branch: "main" }), pullRequest()],    pipeline: pipeline([project.test(), project.lint(), project.fmt()], {      env: { CI: "true" },      defaultImage: "ubuntu:24.04",    }),  },];export default pipelines;

Run it

hm run ci

For a minimal single-binary setup, see the c/ and cpp/ examples in the harmont-cli repo.

On this page