Coverage Report

Created: 2026-06-15 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmGetCMakePropertyCommand.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmGetCMakePropertyCommand.h"
4
5
#include <set>
6
7
#include "cmExecutionStatus.h"
8
#include "cmGlobalGenerator.h"
9
#include "cmList.h"
10
#include "cmMakefile.h"
11
#include "cmPolicies.h"
12
#include "cmState.h"
13
#include "cmValue.h"
14
15
// cmGetCMakePropertyCommand
16
bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
17
                               cmExecutionStatus& status)
18
0
{
19
0
  if (args.size() < 2) {
20
0
    status.SetError("called with incorrect number of arguments");
21
0
    return false;
22
0
  }
23
24
0
  std::string const& variable = args[0];
25
0
  std::string output = "NOTFOUND";
26
27
0
  if (args[1] == "VARIABLES") {
28
0
    if (cmValue varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
29
0
      output = *varsProp;
30
0
    }
31
0
  } else if (args[1] == "MACROS" &&
32
0
             status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0217) !=
33
0
               cmPolicies::NEW) {
34
0
    output.clear();
35
0
    if (cmValue macrosProp = status.GetMakefile().GetProperty("MACROS")) {
36
0
      output = *macrosProp;
37
0
    }
38
0
  } else if (args[1] == "COMPONENTS") {
39
0
    std::set<std::string> const* components =
40
0
      status.GetMakefile().GetGlobalGenerator()->GetInstallComponents();
41
0
    output = cmList::to_string(*components);
42
0
  } else {
43
0
    cmValue prop = nullptr;
44
0
    if (!args[1].empty()) {
45
0
      prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]);
46
0
    }
47
0
    if (prop) {
48
0
      output = *prop;
49
0
    }
50
0
  }
51
52
0
  status.GetMakefile().AddDefinition(variable, output);
53
54
0
  return true;
55
0
}