Merge branch 'release-3.29'
[kiteware-cmake.git] / Source / cmGetCMakePropertyCommand.cxx
blobd2c4fd6b6531489916c0381f7e1b126ae310e5f6
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"
5 #include <set>
7 #include "cmExecutionStatus.h"
8 #include "cmGlobalGenerator.h"
9 #include "cmList.h"
10 #include "cmMakefile.h"
11 #include "cmState.h"
12 #include "cmValue.h"
14 // cmGetCMakePropertyCommand
15 bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
16 cmExecutionStatus& status)
18 if (args.size() < 2) {
19 status.SetError("called with incorrect number of arguments");
20 return false;
23 std::string const& variable = args[0];
24 std::string output = "NOTFOUND";
26 if (args[1] == "VARIABLES") {
27 if (cmValue varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
28 output = *varsProp;
30 } else if (args[1] == "MACROS") {
31 output.clear();
32 if (cmValue macrosProp = status.GetMakefile().GetProperty("MACROS")) {
33 output = *macrosProp;
35 } else if (args[1] == "COMPONENTS") {
36 const std::set<std::string>* components =
37 status.GetMakefile().GetGlobalGenerator()->GetInstallComponents();
38 output = cmList::to_string(*components);
39 } else {
40 cmValue prop = nullptr;
41 if (!args[1].empty()) {
42 prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]);
44 if (prop) {
45 output = *prop;
49 status.GetMakefile().AddDefinition(variable, output);
51 return true;