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