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>
|
|
|
|
|
2016-07-09 11:21:54 +02:00
|
|
|
#include "cmAlgorithms.h"
|
2013-11-03 12:27:13 +02:00
|
|
|
#include "cmGlobalGenerator.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
#include "cmMakefile.h"
|
2015-08-17 11:37:30 +02:00
|
|
|
#include "cmState.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
|
|
|
|
class cmExecutionStatus;
|
2008-10-12 18:41:06 +02:00
|
|
|
|
|
|
|
// cmGetCMakePropertyCommand
|
2016-07-09 11:21:54 +02:00
|
|
|
bool cmGetCMakePropertyCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2008-10-12 18:41:06 +02:00
|
|
|
{
|
2016-07-09 11:21:54 +02:00
|
|
|
if (args.size() < 2) {
|
2008-10-12 18:41:06 +02:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
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") {
|
|
|
|
if (const char* varsProp = this->Makefile->GetProperty("VARIABLES")) {
|
2015-11-17 17:22:37 +01:00
|
|
|
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();
|
2016-07-09 11:21:54 +02:00
|
|
|
if (const char* macrosProp = this->Makefile->GetProperty("MACROS")) {
|
2015-11-17 17:22:37 +01:00
|
|
|
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 =
|
|
|
|
this->Makefile->GetGlobalGenerator()->GetInstallComponents();
|
2015-08-17 11:37:30 +02:00
|
|
|
output = cmJoin(*components, ";");
|
2016-07-09 11:21:54 +02:00
|
|
|
} else {
|
2018-01-26 17:06:56 +01:00
|
|
|
const char* prop = nullptr;
|
2016-07-09 11:21:54 +02:00
|
|
|
if (!args[1].empty()) {
|
2015-11-17 17:22:37 +01:00
|
|
|
prop = this->Makefile->GetState()->GetGlobalProperty(args[1]);
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
|
|
|
if (prop) {
|
2008-10-12 18:41:06 +02:00
|
|
|
output = prop;
|
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2011-06-19 15:41:06 +03:00
|
|
|
|
2015-04-27 22:25:09 +02:00
|
|
|
this->Makefile->AddDefinition(variable, output.c_str());
|
2011-06-19 15:41:06 +03:00
|
|
|
|
2008-10-12 18:41:06 +02:00
|
|
|
return true;
|
|
|
|
}
|