C/C++ Collector
Analyze C/C++ projects to collect build system info (CMake, Make, Meson, Autotools), dependency graphs, cppcheck linting, and CI compiler commands. Enforce C/C++ engineering standards.
cpp to your lunar-config.yml:uses: github://earthly/lunar-lib/collectors/cpp@v1.0.5
What This Integration Collects
This integration includes 5 collectors that gather metadata from your systems.
project
Detects C/C++ project structure including build systems (CMake, Make, Meson, Autotools, Bazel), source file counts, C++ standard version, and package manager configuration (Conan, vcpkg). Writes project metadata to .lang.cpp.
dependencies
Extracts C/C++ dependencies from package managers (Conan, vcpkg) and CMakeLists.txt find_package() calls. Writes dependency data to .lang.cpp.dependencies.
cppcheck
Runs cppcheck static analysis on C/C++ source files. Collects lint warnings with file, line, severity, and message. Writes normalized warnings to .lang.cpp.lint and raw output to .lang.cpp.native.cppcheck.
cicd
Records C/C++ compiler commands (gcc, g++, clang, clang++) executed in CI pipelines along with compiler version. Writes command strings and version info to .lang.cpp.cicd for audit trails and build reproducibility.
cmake-cicd
Records CMake commands executed in CI pipelines along with the CMake version. Writes command strings and version info to .lang.cpp.cicd for build system tracking.
How Collectors Fit into Lunar
Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.
Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.
Learn How Lunar Works →Example Collected Data
This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:
{
"lang": {
"cpp": {
"build_systems": ["cmake", "make"],
"cmake_exists": true,
"makefile_exists": true,
"conanfile_exists": false,
"vcpkg_json_exists": false,
"meson_build_exists": false,
"cpp_standard": "17",
"source_files": {
"c": 5,
"cpp": 23,
"headers": 18
},
"source": { "tool": "cpp", "integration": "code" },
"dependencies": {
"direct": [
{ "name": "boost/1.82.0", "version": "1.82.0", "manager": "conan" }
],
"cmake_packages": ["Boost", "OpenSSL", "Threads"],
"source": { "tool": "cpp", "integration": "code" }
},
"lint": {
"warnings": [
{
"file": "src/main.cpp",
"line": 42,
"severity": "warning",
"message": "Variable 'x' is not initialized",
"id": "uninitvar"
}
],
"tool": "cppcheck",
"source": { "tool": "cppcheck", "integration": "code" }
},
"native": {
"cppcheck": {
"passed": true,
"exit_code": 0,
"error_count": 0,
"warning_count": 1,
"source": { "tool": "cppcheck", "integration": "code" }
}
},
"cicd": {
"cmds": [
{ "cmd": "g++ -std=c++17 -O2 -o main main.cpp", "version": "12.2.0" },
{ "cmd": "cmake --build . --config Release", "version": "3.27.0" }
],
"source": { "tool": "cpp", "integration": "ci" }
}
}
}
}
Documentation
View on GitHubC/C++ Collector
Collects C/C++ project information, build system details, dependencies, and CI commands.
Overview
This collector gathers metadata about C/C++ projects including build system detection (CMake, Make, Meson, Autotools, Bazel), source file inventory, C++ standard version, package manager dependencies (Conan, vcpkg), cppcheck static analysis, and CI/CD compiler command tracking. Runs in a custom cpp-main image with cppcheck pre-installed.
Collected Data
This collector writes to the following Component JSON paths:
| Path | Type | Description |
|---|---|---|
.lang.cpp |
object | C/C++ project metadata (build systems, source files, standards) |
.lang.cpp.build_systems |
array | Detected build systems (e.g., ["cmake", "make"]) |
.lang.cpp.cpp_standard |
string | C++ standard version (e.g., "17", "20") |
.lang.cpp.source_files |
object | Source file counts by type (c, cpp, headers) |
.lang.cpp.dependencies |
object | Dependencies from Conan, vcpkg, and CMake find_package |
.lang.cpp.lint |
object | Normalized lint warnings from cppcheck |
.lang.cpp.native.cppcheck |
object | Raw cppcheck output and status |
.lang.cpp.cicd |
object | CI/CD compiler and build command tracking |
Collectors
This plugin provides the following collectors (use include to select a subset):
| Collector | Hook Type | Description |
|---|---|---|
project |
code | Detects build systems, source files, C++ standard version |
dependencies |
code | Extracts dependencies from Conan, vcpkg, and CMake |
cppcheck |
code | Runs cppcheck static analysis on C/C++ source files |
cicd |
ci-before-command | Tracks C/C++ compiler commands in CI |
cmake-cicd |
ci-before-command | Tracks CMake commands in CI |
Installation
Add to your lunar-config.yml:
collectors:
- uses: github://earthly/lunar-lib/collectors/cpp@v1.0.0
on: ["domain:your-domain"] # replace with your own domain or tags
# include: [project, dependencies] # Only include specific subcollectors
Open Source
This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.
Common Use Cases
Explore guardrails that use data from C/C++ Collector.
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.