Skip to content

cmake_workspace

Imports a checked CMake graph snapshot.

Description

The resolver reads a normalized snapshot produced from CMake's file-based application programming interface. It validates exact configuration input text and selection provenance, then creates one queryable cmake_target per selected configured target and transitive dependency.

This target does not configure or build the project. Pair it with cmake_project for execution.

Attributes

AttributeTypeRequiredDefaultDescription
snapshotstringyesPackage-relative normalized CMake snapshot
resolver_inputslist<string>no[]Snapshot plus every text configuration input supplied to the resolver
source_dirstringno.Source directory recorded in selection provenance
generatorstringnoNinjaCMake generator recorded in selection provenance
build_typestringnoDebugCMake build configuration recorded in selection provenance
exportslist<string>nosnapshot exportsNative CMake names or generated Once names to expose
_cmake_resolvedboolresolver-ownedfalseMarks a workspace expanded by the resolver
_cmake_snapshot_fingerprintstringresolver-ownedemptyCanonical fingerprint from the checked snapshot
_cmake_exportslist<string>resolver-owned[]Generated names selected as roots

The underscore-prefixed attributes are produced by the resolver and should not be set in once.toml.

Dependency Edges

EdgeAcceptsDescription
depscmake_targetResolver-generated logical CMake targets

Providers

The target emits cmake_workspace with the snapshot fingerprint, selected exports, and imported target provider records.

Capabilities

This target has no executable capability.

Example

toml
[[target]]
name = "CMakeGraph"
kind = "cmake_workspace"
srcs = ["CMakeLists.txt", "cmake-snapshot.json"]

[target.attrs]
snapshot = "cmake-snapshot.json"
resolver_inputs = ["CMakeLists.txt", "cmake-snapshot.json"]
generator = "Ninja"
build_type = "Release"
exports = ["greeting"]

Graph loading rejects the snapshot when a bound input or selection value changes. See the CMake guide for the explicit refresh workflow.

Released under an open-source license.