Crates.io | cmake-parser-derive |
lib.rs | cmake-parser-derive |
version | 0.1.0-beta.1 |
source | src |
created_at | 2024-05-02 05:58:38.943725 |
updated_at | 2024-09-21 21:36:54.724752 |
description | The derive macros to parse cmake language using cmake-parser library. |
homepage | https://github.com/rust-utility/cmake-parser |
repository | https://github.com/rust-utility/cmake-parser |
max_upload_size | |
id | 1227478 |
size | 41,234 |
cmake-parser
is a Rust library that provides a set of tools for parsing CMake files and working with the data they contain. The library includes a parser for reading CMake files, as well as several structs and enums for representing the data defined in CMake files.
CMake version: v3.26
CMake Language specification:
https://cmake.org/cmake/help/v3.26/manual/cmake-language.7.html
The cmake-parser
library provides the following features:
CMakeLists.txt
files: The library includes a parser for reading CMakeLists.txt
files and extracting the data defined in them.Add dependency to Cargo.toml
:
[dependencies]
cmake-parser = "0.1"
Example src/main.rs
:
use cmake_parser::{parse_cmakelists, Command, Doc};
let cmakelists = br#"
add_custom_command(
TARGET myExe POST_BUILD
COMMAND someHasher -i "$<TARGET_FILE:myExe>"
-o "$<TARGET_FILE:myExe>.hash"
VERBATIM)
"#;
let cmakelists = parse_cmakelists(cmakelists).expect("valid CMakeLists.txt");
let doc = Doc::from(cmakelists);
let commands = doc.commands().expect("valid CMake commands");
assert!(matches!(
commands.as_slice(),
[Command::AddCustomCommand(_)]
));
dbg!(commands);
Implemented: 127 of 127.
These commands are always available.
These commands are available only in CMake projects.
These commands are available only in CTest scripts.
These commands are deprecated and are only made available to maintain backward compatibility. The documentation of each command states the CMake version in which it was deprecated. Do not use these commands in new code.