Skip to content

cmake_project

Cacheable coarse build boundary for an existing CMake project.

Description

The target keeps CMake authoritative. It resolves and probes CMake plus the generated-build program, writes a portable CMake driver, and runs configure followed by cmake --build in one action. It stages only explicitly declared product files into the stable target output directory.

The target also exposes declared headers, include directories, definitions, link options, libraries, and data through the shared native provider shape. Use cmake_workspace when the configured CMake graph should also be queryable.

Attributes

AttributeTypeRequiredDefaultDescription
cmakestringnocmakeCMake executable name or path
source_dirstringno.Package-relative CMake source directory
generatorstringnoNinjaCMake generated-build backend
build_programstringnoninja for NinjaGenerated-build executable name or path
build_typestringnoDebugCMake build configuration
configure_argslist<string>no[]Additional CMake configure arguments
build_targetslist<string>no[]Native CMake targets passed to the generated build
build_argslist<string>no[]Additional arguments passed to cmake --build
productslist<string>yesExact files expected under the generated build directory
hdrslist<string>no[]Public package-relative headers
header_globslist<string>no[]Public header patterns
includeslist<string>no[]Public include directories
defineslist<string>no[]Public preprocessor definitions
linkoptslist<string>no[]Linker options propagated to dependents
datalist<string>no[]Runtime data patterns propagated to dependents
envmap<string, string>no{}Environment variables passed to configure and build

Product paths support {static_prefix}, {static_suffix}, {shared_prefix}, {shared_suffix}, and {exe_suffix}. Absolute paths and paths that escape the generated build directory are rejected.

Dependency Edges

EdgeAcceptsDescription
depsc_providerNative headers, libraries, and data included in the CMake action input tree

Providers

The target emits cmake_project, c_provider, native_linkable, and apple_linkable.

The provider includes products, direct and transitive headers, include directories, definitions, static libraries, dynamic libraries, link options, data, affected inputs, and default_output.

Capabilities

CapabilityOutput groups
builddefault, products, library

Example

toml
[[target]]
name = "CMakeProject"
kind = "cmake_project"
srcs = ["CMakeLists.txt", "include/**/*.h", "src/**/*.c"]

[target.attrs]
generator = "Ninja"
build_type = "Release"
build_targets = ["greeting"]
products = ["{static_prefix}greeting{static_suffix}"]
hdrs = ["include/greeting.h"]
includes = ["include"]

See the CMake guide for the snapshot refresh and query workflow.

Released under an open-source license.