cmake_parser/doc/command/deprecated/
utility_source.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    doc::command_scope::{CommandScope, ToCommandScope},
5    Token,
6};
7
8/// Specify the source tree of a third-party utility.
9///
10/// Reference: <https://cmake.org/cmake/help/v3.26/command/utility_source.html>
11#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate", positional)]
13pub struct UtilitySource<'t> {
14    pub cache_entry: Token<'t>,
15    pub executable_name: Token<'t>,
16    pub path_to_source: Token<'t>,
17    pub files: Option<Vec<Token<'t>>>,
18}
19
20impl<'t> ToCommandScope for UtilitySource<'t> {
21    fn to_command_scope(&self) -> CommandScope {
22        CommandScope::Deprecated
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    use crate::doc::cmake_parse::tests::{token, tokens_vec};
30    use crate::*;
31    use pretty_assertions::assert_eq;
32
33    #[test]
34    fn utility_source() {
35        let src = include_bytes!("../../../../../fixture/commands/deprecated/utility_source");
36        let cmakelists = parse_cmakelists(src).unwrap();
37        let doc = Doc::from(cmakelists);
38        assert_eq!(
39            doc.commands(),
40            Ok(vec![Command::UtilitySource(Box::new(UtilitySource {
41                cache_entry: token(b"cache_entry1"),
42                executable_name: token(b"executable_name1"),
43                path_to_source: token(b"path_to_source1"),
44                files: Some(tokens_vec([b"file1", b"file2"])),
45            })),])
46        )
47    }
48}