cmake_parser/doc/command/project/
include_directories.rs1use cmake_parser_derive::CMake;
2
3use crate::{
4 command::common::Append,
5 doc::command_scope::{CommandScope, ToCommandScope},
6 Token,
7};
8
9#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
13#[cmake(pkg = "crate", positional)]
14pub struct IncludeDirectories<'t> {
15 pub append: Option<Append>,
16 pub system: bool,
17 pub dirs: Vec<Token<'t>>,
18}
19
20impl<'t> ToCommandScope for IncludeDirectories<'t> {
21 fn to_command_scope(&self) -> CommandScope {
22 CommandScope::Project
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29 use crate::doc::cmake_parse::tests::tokens_vec;
30 use crate::*;
31 use pretty_assertions::assert_eq;
32
33 #[test]
34 fn include_directories() {
35 let src = include_bytes!("../../../../../fixture/commands/project/include_directories");
36 let cmakelists = parse_cmakelists(src).unwrap();
37 let doc = Doc::from(cmakelists);
38 assert_eq!(
39 doc.commands(),
40 Ok(vec![
41 Command::IncludeDirectories(Box::new(IncludeDirectories {
42 append: None,
43 system: false,
44 dirs: tokens_vec([b"include"])
45 })),
46 Command::IncludeDirectories(Box::new(IncludeDirectories {
47 append: Some(Append::Before),
48 system: false,
49 dirs: tokens_vec([b"include1", b"include2"])
50 })),
51 Command::IncludeDirectories(Box::new(IncludeDirectories {
52 append: Some(Append::After),
53 system: true,
54 dirs: tokens_vec([b"include1"])
55 })),
56 ])
57 )
58 }
59}