/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 "cmState.h" |
12 | | #include "cmValue.h" |
13 | | |
14 | | // cmGetCMakePropertyCommand |
15 | | bool cmGetCMakePropertyCommand(std::vector<std::string> const& args, |
16 | | cmExecutionStatus& status) |
17 | 0 | { |
18 | 0 | if (args.size() < 2) { |
19 | 0 | status.SetError("called with incorrect number of arguments"); |
20 | 0 | return false; |
21 | 0 | } |
22 | | |
23 | 0 | std::string const& variable = args[0]; |
24 | 0 | std::string output = "NOTFOUND"; |
25 | |
|
26 | 0 | if (args[1] == "VARIABLES") { |
27 | 0 | if (cmValue varsProp = status.GetMakefile().GetProperty("VARIABLES")) { |
28 | 0 | output = *varsProp; |
29 | 0 | } |
30 | 0 | } else if (args[1] == "MACROS") { |
31 | 0 | output.clear(); |
32 | 0 | if (cmValue macrosProp = status.GetMakefile().GetProperty("MACROS")) { |
33 | 0 | output = *macrosProp; |
34 | 0 | } |
35 | 0 | } else if (args[1] == "COMPONENTS") { |
36 | 0 | std::set<std::string> const* components = |
37 | 0 | status.GetMakefile().GetGlobalGenerator()->GetInstallComponents(); |
38 | 0 | output = cmList::to_string(*components); |
39 | 0 | } else { |
40 | 0 | cmValue prop = nullptr; |
41 | 0 | if (!args[1].empty()) { |
42 | 0 | prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]); |
43 | 0 | } |
44 | 0 | if (prop) { |
45 | 0 | output = *prop; |
46 | 0 | } |
47 | 0 | } |
48 | |
|
49 | 0 | status.GetMakefile().AddDefinition(variable, output); |
50 | |
|
51 | 0 | return true; |
52 | 0 | } |