mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
cmCommand refactor: cmGetCMakePropertyCommand
This commit is contained in:
@@ -135,8 +135,7 @@ void GetScriptingCommands(cmState* state)
|
||||
cm::make_unique<cmFindProgramCommand>());
|
||||
state->AddBuiltinCommand("foreach", cmForEachCommand);
|
||||
state->AddBuiltinCommand("function", cmFunctionCommand);
|
||||
state->AddBuiltinCommand("get_cmake_property",
|
||||
cm::make_unique<cmGetCMakePropertyCommand>());
|
||||
state->AddBuiltinCommand("get_cmake_property", cmGetCMakePropertyCommand);
|
||||
state->AddBuiltinCommand("get_directory_property",
|
||||
cm::make_unique<cmGetDirectoryPropertyCommand>());
|
||||
state->AddBuiltinCommand("get_filename_component",
|
||||
|
||||
@@ -4,19 +4,18 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
// cmGetCMakePropertyCommand
|
||||
bool cmGetCMakePropertyCommand::InitialPass(
|
||||
std::vector<std::string> const& args, cmExecutionStatus&)
|
||||
bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.size() < 2) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,29 +23,29 @@ bool cmGetCMakePropertyCommand::InitialPass(
|
||||
std::string output = "NOTFOUND";
|
||||
|
||||
if (args[1] == "VARIABLES") {
|
||||
if (const char* varsProp = this->Makefile->GetProperty("VARIABLES")) {
|
||||
if (const char* varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
|
||||
output = varsProp;
|
||||
}
|
||||
} else if (args[1] == "MACROS") {
|
||||
output.clear();
|
||||
if (const char* macrosProp = this->Makefile->GetProperty("MACROS")) {
|
||||
if (const char* macrosProp = status.GetMakefile().GetProperty("MACROS")) {
|
||||
output = macrosProp;
|
||||
}
|
||||
} else if (args[1] == "COMPONENTS") {
|
||||
const std::set<std::string>* components =
|
||||
this->Makefile->GetGlobalGenerator()->GetInstallComponents();
|
||||
status.GetMakefile().GetGlobalGenerator()->GetInstallComponents();
|
||||
output = cmJoin(*components, ";");
|
||||
} else {
|
||||
const char* prop = nullptr;
|
||||
if (!args[1].empty()) {
|
||||
prop = this->Makefile->GetState()->GetGlobalProperty(args[1]);
|
||||
prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]);
|
||||
}
|
||||
if (prop) {
|
||||
output = prop;
|
||||
}
|
||||
}
|
||||
|
||||
this->Makefile->AddDefinition(variable, output);
|
||||
status.GetMakefile().AddDefinition(variable, output);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,26 +8,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmCommand.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
class cmGetCMakePropertyCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<cmCommand> Clone() override
|
||||
{
|
||||
return cm::make_unique<cmGetCMakePropertyCommand>();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when the command is first encountered in
|
||||
* the input file.
|
||||
*/
|
||||
bool InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status) override;
|
||||
};
|
||||
bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user