cmake_parser/doc/command/deprecated/
install_targets.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    doc::command_scope::{CommandScope, ToCommandScope},
5    Token,
6};
7
8/// Create rules to install the listed targets into the given directory.
9///
10/// Reference: <https://cmake.org/cmake/help/v3.26/command/install_targets.html>
11#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate", default = "targets")]
13pub struct InstallTargets<'t> {
14    #[cmake(positional)]
15    pub dir: Token<'t>,
16    pub runtime_directory: Option<Token<'t>>,
17    pub targets: Vec<Token<'t>>,
18}
19
20impl<'t> ToCommandScope for InstallTargets<'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 install_targets() {
35        let src = include_bytes!("../../../../../fixture/commands/deprecated/install_targets");
36        let cmakelists = parse_cmakelists(src).unwrap();
37        let doc = Doc::from(cmakelists);
38        assert_eq!(
39            doc.commands(),
40            Ok(vec![
41                Command::InstallTargets(Box::new(InstallTargets {
42                    dir: token(b"dir1"),
43                    runtime_directory: Some(token(b"dir2")),
44                    targets: tokens_vec([b"target1", b"target2"]),
45                })),
46                Command::InstallTargets(Box::new(InstallTargets {
47                    dir: token(b"dir1"),
48                    runtime_directory: None,
49                    targets: tokens_vec([b"target1", b"target2"]),
50                })),
51            ])
52        )
53    }
54}