cmake_parser/doc/command/project/
include_external_msproject.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    doc::command_scope::{CommandScope, ToCommandScope},
5    Token,
6};
7
8/// Include an external Microsoft project file in a workspace.
9///
10/// Reference: <https://cmake.org/cmake/help/v3.26/command/include_external_msproject.html>
11#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate", default = "deps")]
13pub struct IncludeExternalMSProject<'t> {
14    #[cmake(positional)]
15    pub project_name: Token<'t>,
16    #[cmake(positional)]
17    pub location: Token<'t>,
18    #[cmake(rename = "TYPE")]
19    pub project_type: Option<Token<'t>>,
20    pub guid: Option<Token<'t>>,
21    pub platform: Option<Token<'t>>,
22    #[cmake(rename = "")]
23    pub deps: Option<Vec<Token<'t>>>,
24}
25
26impl<'t> ToCommandScope for IncludeExternalMSProject<'t> {
27    fn to_command_scope(&self) -> CommandScope {
28        CommandScope::Project
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35    use crate::doc::cmake_parse::tests::token;
36    use crate::*;
37    use pretty_assertions::assert_eq;
38
39    #[test]
40    fn include_external_msproject() {
41        let src =
42            include_bytes!("../../../../../fixture/commands/project/include_external_msproject");
43        let cmakelists = parse_cmakelists(src).unwrap();
44        let doc = Doc::from(cmakelists);
45        assert_eq!(
46            doc.commands(),
47            Ok(vec![Command::IncludeExternalMSProject(Box::new(
48                IncludeExternalMSProject {
49                    project_name: token(b"splash"),
50                    location: token(b"${CMAKE_SOURCE_DIR}/splash.vcxproj"),
51                    project_type: None,
52                    guid: None,
53                    platform: Some(token(b"Win32")),
54                    deps: None,
55                }
56            )),])
57        )
58    }
59}