Hamburger Cross Icon
C/C++ Collector - Lunar Collector

C/C++ Collector

Collector Beta LanguagesBuild

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.

Add 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.

Collector code

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.

c++ c cmake makefile meson project structure
Book a demo
Collector code

dependencies

Extracts C/C++ dependencies from package managers (Conan, vcpkg) and CMakeLists.txt find_package() calls. Writes dependency data to .lang.cpp.dependencies.

c++ dependencies conan vcpkg cmake packages supply chain
Book a demo
Collector code

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.

cppcheck c++ linting static analysis code quality
Book a demo
Collector ci-before-command

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.

c++ ci compiler version gcc clang ci commands
Book a demo
Collector ci-before-command

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.

cmake ci cmake version build system tracking
Book a demo

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
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "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 GitHub

C/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.

View Repository

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.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo