kilork.github.io

cmake-parser

A Rust parser for CMake files (language 3.26).

A lot of the C and C++ world describes itself in CMake. If a tool needs to know what a project builds — targets, sources, flags — the honest way is to parse those files rather than pattern-match them.

What changes for you

Getting it

cargo add cmake-parser
use cmake_parser::parse_cmakelists;

for command in parse_cmakelists(text)? {
    // command.name, command.arguments, ...
}

Where to look

source · crate