cmake_parser/doc/command/project/
add_subdirectory.rs1use ::cmake_parser_derive::CMake;
2
3use crate::{CommandScope, ToCommandScope, Token};
4
5#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[cmake(pkg = "crate", default = "binary_dir")]
10pub struct AddSubdirectory<'t> {
11 #[cmake(positional)]
12 source_dir: Token<'t>,
13 #[cmake(rename = "")]
14 binary_dir: Option<Token<'t>>,
15 exclude_from_all: bool,
16 system: bool,
17}
18
19impl<'t> ToCommandScope for AddSubdirectory<'t> {
20 fn to_command_scope(&self) -> CommandScope {
21 CommandScope::Project
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28 use crate::*;
29
30 #[test]
31 fn add_subdirectory() {
32 let src = include_bytes!("../../../../../fixture/commands/project/add_subdirectory");
33 let cmakelists = parse_cmakelists(src).unwrap();
34 let doc = Doc::from(cmakelists);
35 assert_eq!(
36 doc.commands(),
37 Ok(vec![
38 Command::AddSubdirectory(Box::new(AddSubdirectory {
39 source_dir: b"libs".into(),
40 binary_dir: Some(b"qqq".into()),
41 exclude_from_all: false,
42 system: false,
43 })),
44 Command::AddSubdirectory(Box::new(AddSubdirectory {
45 source_dir: b"lib/${EDGE_SOURCES_DIR_NAME}/nano-stack".into(),
46 binary_dir: None,
47 exclude_from_all: false,
48 system: false,
49 })),
50 Command::AddSubdirectory(Box::new(AddSubdirectory {
51 source_dir: b"libs".into(),
52 binary_dir: None,
53 exclude_from_all: true,
54 system: true,
55 })),
56 Command::AddSubdirectory(Box::new(AddSubdirectory {
57 source_dir: b"libs".into(),
58 binary_dir: Some(b"qqq".into()),
59 exclude_from_all: false,
60 system: true,
61 })),
62 ])
63 )
64 }
65}