2016-10-30 18:24:19 +01:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2008-10-12 18:41:06 +02:00
|
|
|
#include "cmGetCMakePropertyCommand.h"
|
|
|
|
|
2017-04-14 19:02:05 +02:00
|
|
|
#include <set>
|
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
#include "cmExecutionStatus.h"
|
2013-11-03 12:27:13 +02:00
|
|
|
#include "cmGlobalGenerator.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
#include "cmMakefile.h"
|
2020-08-30 11:54:41 +02:00
|
|
|
#include "cmProperty.h"
|
2015-08-17 11:37:30 +02:00
|
|
|
#include "cmState.h"
|
2020-02-01 23:06:01 +01:00
|
|
|
#include "cmStringAlgorithms.h"
|
2008-10-12 18:41:06 +02:00
|
|
|
|
|
|
|
// cmGetCMakePropertyCommand
|
2020-02-01 23:06:01 +01:00
|
|
|
bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus& status)
|
2008-10-12 18:41:06 +02:00
|
|
|
{
|
2016-07-09 11:21:54 +02:00
|
|
|
if (args.size() < 2) {
|
2020-02-01 23:06:01 +01:00
|
|
|
status.SetError("called with incorrect number of arguments");
|
2008-10-12 18:41:06 +02:00
|
|
|
return false;
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2011-06-19 15:41:06 +03:00
|
|
|
|
2017-07-20 19:35:53 +02:00
|
|
|
std::string const& variable = args[0];
|
2008-10-12 18:41:06 +02:00
|
|
|
std::string output = "NOTFOUND";
|
|
|
|
|
2016-07-09 11:21:54 +02:00
|
|
|
if (args[1] == "VARIABLES") {
|
2020-08-30 11:54:41 +02:00
|
|
|
if (cmProp varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
|
|
|
|
output = *varsProp;
|
2008-10-12 18:41:06 +02:00
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
} else if (args[1] == "MACROS") {
|
2015-08-17 11:37:30 +02:00
|
|
|
output.clear();
|
2020-08-30 11:54:41 +02:00
|
|
|
if (cmProp macrosProp = status.GetMakefile().GetProperty("MACROS")) {
|
|
|
|
output = *macrosProp;
|
2008-10-12 18:41:06 +02:00
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
} else if (args[1] == "COMPONENTS") {
|
|
|
|
const std::set<std::string>* components =
|
2020-02-01 23:06:01 +01:00
|
|
|
status.GetMakefile().GetGlobalGenerator()->GetInstallComponents();
|
2015-08-17 11:37:30 +02:00
|
|
|
output = cmJoin(*components, ";");
|
2016-07-09 11:21:54 +02:00
|
|
|
} else {
|
2020-08-30 11:54:41 +02:00
|
|
|
cmProp prop = nullptr;
|
2016-07-09 11:21:54 +02:00
|
|
|
if (!args[1].empty()) {
|
2020-02-01 23:06:01 +01:00
|
|
|
prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]);
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
|
|
|
if (prop) {
|
2020-08-30 11:54:41 +02:00
|
|
|
output = *prop;
|
2008-10-12 18:41:06 +02:00
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2011-06-19 15:41:06 +03:00
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
status.GetMakefile().AddDefinition(variable, output);
|
2011-06-19 15:41:06 +03:00
|
|
|
|
2008-10-12 18:41:06 +02:00
|
|
|
return true;
|
|
|
|
}
|