mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
cmCommand refactor: cmSetDirectoryPropertiesCommand
This commit is contained in:
@@ -155,7 +155,7 @@ void GetScriptingCommands(cmState* state)
|
|||||||
state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand);
|
state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand);
|
||||||
state->AddBuiltinCommand("set", cmSetCommand);
|
state->AddBuiltinCommand("set", cmSetCommand);
|
||||||
state->AddBuiltinCommand("set_directory_properties",
|
state->AddBuiltinCommand("set_directory_properties",
|
||||||
cm::make_unique<cmSetDirectoryPropertiesCommand>());
|
cmSetDirectoryPropertiesCommand);
|
||||||
state->AddBuiltinCommand("set_property",
|
state->AddBuiltinCommand("set_property",
|
||||||
cm::make_unique<cmSetPropertyCommand>());
|
cm::make_unique<cmSetPropertyCommand>());
|
||||||
state->AddBuiltinCommand("site_name", cmSiteNameCommand);
|
state->AddBuiltinCommand("site_name", cmSiteNameCommand);
|
||||||
|
@@ -2,31 +2,37 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmSetDirectoryPropertiesCommand.h"
|
#include "cmSetDirectoryPropertiesCommand.h"
|
||||||
|
|
||||||
|
#include "cmExecutionStatus.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
class cmExecutionStatus;
|
namespace {
|
||||||
|
bool RunCommand(cmMakefile& mf, std::vector<std::string>::const_iterator ait,
|
||||||
|
std::vector<std::string>::const_iterator aitend,
|
||||||
|
std::string& errors);
|
||||||
|
}
|
||||||
|
|
||||||
// cmSetDirectoryPropertiesCommand
|
// cmSetDirectoryPropertiesCommand
|
||||||
bool cmSetDirectoryPropertiesCommand::InitialPass(
|
bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
|
||||||
std::vector<std::string> const& args, cmExecutionStatus&)
|
cmExecutionStatus& status)
|
||||||
{
|
{
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
this->SetError("called with incorrect number of arguments");
|
status.SetError("called with incorrect number of arguments");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string errors;
|
std::string errors;
|
||||||
bool ret = cmSetDirectoryPropertiesCommand::RunCommand(
|
bool ret =
|
||||||
this->Makefile, args.begin() + 1, args.end(), errors);
|
RunCommand(status.GetMakefile(), args.begin() + 1, args.end(), errors);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
this->SetError(errors);
|
status.SetError(errors);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmSetDirectoryPropertiesCommand::RunCommand(
|
namespace {
|
||||||
cmMakefile* mf, std::vector<std::string>::const_iterator ait,
|
bool RunCommand(cmMakefile& mf, std::vector<std::string>::const_iterator ait,
|
||||||
std::vector<std::string>::const_iterator aitend, std::string& errors)
|
std::vector<std::string>::const_iterator aitend,
|
||||||
|
std::string& errors)
|
||||||
{
|
{
|
||||||
for (; ait != aitend; ait += 2) {
|
for (; ait != aitend; ait += 2) {
|
||||||
if (ait + 1 == aitend) {
|
if (ait + 1 == aitend) {
|
||||||
@@ -43,8 +49,9 @@ bool cmSetDirectoryPropertiesCommand::RunCommand(
|
|||||||
errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
|
errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mf->SetProperty(prop, value.c_str());
|
mf.SetProperty(prop, value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -8,35 +8,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cm_memory.hxx"
|
|
||||||
|
|
||||||
#include "cmCommand.h"
|
|
||||||
|
|
||||||
class cmExecutionStatus;
|
class cmExecutionStatus;
|
||||||
class cmMakefile;
|
|
||||||
|
|
||||||
class cmSetDirectoryPropertiesCommand : public cmCommand
|
bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
|
||||||
{
|
cmExecutionStatus& status);
|
||||||
public:
|
|
||||||
std::unique_ptr<cmCommand> Clone() override
|
|
||||||
{
|
|
||||||
return cm::make_unique<cmSetDirectoryPropertiesCommand>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is called when the command is first encountered in
|
|
||||||
* the input file.
|
|
||||||
*/
|
|
||||||
bool InitialPass(std::vector<std::string> const& args,
|
|
||||||
cmExecutionStatus& status) override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static entry point for use by other commands
|
|
||||||
*/
|
|
||||||
static bool RunCommand(cmMakefile* mf,
|
|
||||||
std::vector<std::string>::const_iterator ait,
|
|
||||||
std::vector<std::string>::const_iterator aitend,
|
|
||||||
std::string& errors);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user