--- id: tree-sitter-cmake version: "0.7.2.post1" license: MIT license_treatment: permissive maintenance: active --- # tree-sitter-cmake — CMake grammar for tree-sitter License: permissive · Maintenance: active · Downloads: 74.4K/mo ## What it is and what it does tree-sitter-cmake is a Python binding for a tree-sitter grammar that parses CMake code into a syntax tree. It wraps the grammar from the uyha/tree-sitter-cmake repository and exposes it through a simple Python API. You supply CMake source code as bytes, initialize a tree-sitter Parser with the CMake language, and receive back a traversable syntax tree representing commands, arguments, variables, and comments. The package is designed for developers who need to analyze, transform, or validate CMake files programmatically. It supports general commands, flow control (if, while, foreach), functions, macros, quoted and bracket arguments, variable references, and both line and bracket comments. Use it for: - Build system analysis: extract and inspect CMake project structure, dependencies, and compiler flags - CMake linting or validation: traverse the syntax tree to enforce coding standards or detect errors - Code generation: programmatically modify or generate CMake files by manipulating the parsed tree - Documentation extraction: parse CMake files to auto-generate build documentation or dependency graphs - IDE integration: provide syntax highlighting, code completion, or error reporting for CMake editors ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a tree-sitter grammar for parsing CMake code, enabling incremental syntax analysis of CMake files in Python applications. Yes, if you need to parse or analyze CMake code programmatically in Python. The package is actively maintained, permissively licensed, and has no known vulnerabilities. Medium install friction is typical for tree-sitter bindings. Requires Python >= 3.10 and tree-sitter ~= 0.24. ## Install pip install tree-sitter-cmake uv add tree-sitter-cmake poetry add tree-sitter-cmake ## Installing tree-sitter-cmake Before you install: Medium install friction due to platform-specific wheels; actively maintained with last commit on 2026-07-08. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal obligations—suitable for both open and closed-source projects. Quickstart: pip install tree-sitter-cmake import tree_sitter_cmake import tree_sitter cmake_language = tree_sitter.Language(tree_sitter_cmake.language()) parser = tree_sitter.Parser(cmake_language) tree = parser.parse(b"cmake_minimum_required(VERSION 3.10)") print(tree.root_node) Requires Python >= 3.10 and tree-sitter ~= 0.24 Verify before relying: - Whether tree-sitter ~= 0.24 is automatically installed or must be manually added - Performance characteristics when parsing large or deeply nested CMake files - Completeness of grammar coverage for CMake syntax beyond documented constructs ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 74.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags cmake parser python, tree-sitter cmake grammar, cmake syntax tree, incremental cmake parsing, cmake ast extraction, cmake code analysis, parsing, cmake, build-tools [View on SkillFed](https://skillfed.io/packages/tree-sitter-cmake) · [View on PyPI](https://pypi.org/project/tree-sitter-cmake/)