cmake_parser/doc/command/scripting/
set_directory_properties.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    command::common::Property,
5    doc::command_scope::{CommandScope, ToCommandScope},
6};
7
8/// Set properties of the current directory and subdirectories.
9///
10/// Reference: <https://cmake.org/cmake/help/v3.26/command/set_directory_properties.html>
11#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate", positional)]
13pub struct SetDirectoryProperties<'t> {
14    #[cmake(transparent)]
15    pub properties: Vec<Property<'t>>,
16}
17
18impl<'t> ToCommandScope for SetDirectoryProperties<'t> {
19    fn to_command_scope(&self) -> CommandScope {
20        CommandScope::Scripting
21    }
22}
23
24#[cfg(test)]
25mod tests {
26    use super::*;
27    use crate::doc::cmake_parse::tests::token;
28    use crate::*;
29    use pretty_assertions::assert_eq;
30
31    #[test]
32    fn set_directory_properties() {
33        let src =
34            include_bytes!("../../../../../fixture/commands/scripting/set_directory_properties");
35        let cmakelists = parse_cmakelists(src).unwrap();
36        let doc = Doc::from(cmakelists);
37        assert_eq!(
38            doc.to_commands_iter().collect::<Vec<_>>(),
39            vec![
40                Ok(Command::SetDirectoryProperties(Box::new(
41                    SetDirectoryProperties {
42                        properties: vec![Property {
43                            prop: token(b"prop1"),
44                            value: token(b"value1")
45                        }],
46                    }
47                ))),
48                Ok(Command::SetDirectoryProperties(Box::new(
49                    SetDirectoryProperties {
50                        properties: vec![
51                            Property {
52                                prop: token(b"prop1"),
53                                value: token(b"value1")
54                            },
55                            Property {
56                                prop: token(b"prop2"),
57                                value: token(b"value2")
58                            }
59                        ],
60                    }
61                ))),
62            ]
63        )
64    }
65}