resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmGetCMakePropertyCommand.cxx
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt 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 "cmMakefile.h"
10 #include "cmState.h"
11 #include "cmStringAlgorithms.h"
12 #include "cmValue.h"
13
14 // cmGetCMakePropertyCommand
15 bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
16                                cmExecutionStatus& status)
17 {
18   if (args.size() < 2) {
19     status.SetError("called with incorrect number of arguments");
20     return false;
21   }
22
23   std::string const& variable = args[0];
24   std::string output = "NOTFOUND";
25
26   if (args[1] == "VARIABLES") {
27     if (cmValue varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
28       output = *varsProp;
29     }
30   } else if (args[1] == "MACROS") {
31     output.clear();
32     if (cmValue macrosProp = status.GetMakefile().GetProperty("MACROS")) {
33       output = *macrosProp;
34     }
35   } else if (args[1] == "COMPONENTS") {
36     const std::set<std::string>* components =
37       status.GetMakefile().GetGlobalGenerator()->GetInstallComponents();
38     output = cmJoin(*components, ";");
39   } else {
40     cmValue prop = nullptr;
41     if (!args[1].empty()) {
42       prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]);
43     }
44     if (prop) {
45       output = *prop;
46     }
47   }
48
49   status.GetMakefile().AddDefinition(variable, output);
50
51   return true;
52 }