cmake_parser/doc/command/project/
remove_definitions.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    doc::command_scope::{CommandScope, ToCommandScope},
5    Token,
6};
7
8/// Remove -D define flags added by add_definitions().
9///
10/// Reference: <https://cmake.org/cmake/help/v3.26/command/remove_definitions.html>
11#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate")]
13pub struct RemoveDefinitions<'t> {
14    #[cmake(positional)]
15    pub definitions: Vec<Token<'t>>,
16}
17
18impl<'t> ToCommandScope for RemoveDefinitions<'t> {
19    fn to_command_scope(&self) -> CommandScope {
20        CommandScope::Project
21    }
22}
23
24#[cfg(test)]
25mod tests {
26    use super::*;
27    use crate::doc::cmake_parse::tests::tokens_vec;
28    use crate::*;
29
30    #[test]
31    fn remove_definitions() {
32        let src = include_bytes!("../../../../../fixture/commands/project/remove_definitions");
33        let cmakelists = parse_cmakelists(src).unwrap();
34        let doc = Doc::from(cmakelists);
35        assert_eq!(
36            doc.commands(),
37            Ok(vec![Command::RemoveDefinitions(Box::new(
38                RemoveDefinitions {
39                    definitions: tokens_vec([b"-DFOO", b"-DBAR"])
40                }
41            ))])
42        )
43    }
44}