cmake_parser/doc/command/scripting/
include_guard.rs1use cmake_parser_derive::CMake;
2
3use crate::doc::command_scope::{CommandScope, ToCommandScope};
4
5#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[cmake(pkg = "crate", positional)]
10pub struct IncludeGuard {
11 pub scope: Option<Scope>,
12}
13
14impl ToCommandScope for IncludeGuard {
15 fn to_command_scope(&self) -> CommandScope {
16 CommandScope::Scripting
17 }
18}
19
20#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
21#[cmake(pkg = "crate", list)]
22pub enum Scope {
23 Directory,
24 Global,
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30 use crate::*;
31 use pretty_assertions::assert_eq;
32
33 #[test]
34 fn include_guard() {
35 let src = include_bytes!("../../../../../fixture/commands/scripting/include_guard");
36 let cmakelists = parse_cmakelists(src).unwrap();
37 let doc = Doc::from(cmakelists);
38 assert_eq!(
39 doc.to_commands_iter().collect::<Vec<_>>(),
40 vec![
41 Ok(Command::IncludeGuard(Box::new(IncludeGuard {
42 scope: None,
43 }))),
44 Ok(Command::IncludeGuard(Box::new(IncludeGuard {
45 scope: Some(Scope::Directory),
46 }))),
47 Ok(Command::IncludeGuard(Box::new(IncludeGuard {
48 scope: Some(Scope::Global),
49 }))),
50 ]
51 )
52 }
53}