mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 20:46:37 +08:00
cmCommand refactor: cmRemoveCommand
This commit is contained in:
@@ -202,7 +202,7 @@ void GetScriptingCommands(cmState* state)
|
|||||||
#if !defined(CMAKE_BOOTSTRAP)
|
#if !defined(CMAKE_BOOTSTRAP)
|
||||||
state->AddBuiltinCommand("cmake_host_system_information",
|
state->AddBuiltinCommand("cmake_host_system_information",
|
||||||
cmCMakeHostSystemInformationCommand);
|
cmCMakeHostSystemInformationCommand);
|
||||||
state->AddBuiltinCommand("remove", cm::make_unique<cmRemoveCommand>());
|
state->AddBuiltinCommand("remove", cmRemoveCommand);
|
||||||
state->AddBuiltinCommand("variable_watch",
|
state->AddBuiltinCommand("variable_watch",
|
||||||
cm::make_unique<cmVariableWatchCommand>());
|
cm::make_unique<cmVariableWatchCommand>());
|
||||||
state->AddBuiltinCommand("write_file",
|
state->AddBuiltinCommand("write_file",
|
||||||
|
@@ -2,14 +2,13 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmRemoveCommand.h"
|
#include "cmRemoveCommand.h"
|
||||||
|
|
||||||
|
#include "cmExecutionStatus.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
|
|
||||||
class cmExecutionStatus;
|
|
||||||
|
|
||||||
// cmRemoveCommand
|
// cmRemoveCommand
|
||||||
bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
|
bool cmRemoveCommand(std::vector<std::string> const& args,
|
||||||
cmExecutionStatus&)
|
cmExecutionStatus& status)
|
||||||
{
|
{
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
return true;
|
return true;
|
||||||
@@ -17,7 +16,7 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
|
|
||||||
std::string const& variable = args[0]; // VAR is always first
|
std::string const& variable = args[0]; // VAR is always first
|
||||||
// get the old value
|
// get the old value
|
||||||
const char* cacheValue = this->Makefile->GetDefinition(variable);
|
const char* cacheValue = status.GetMakefile().GetDefinition(variable);
|
||||||
|
|
||||||
// if there is no old value then return
|
// if there is no old value then return
|
||||||
if (!cacheValue) {
|
if (!cacheValue) {
|
||||||
@@ -51,7 +50,7 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add the definition
|
// add the definition
|
||||||
this->Makefile->AddDefinition(variable, value);
|
status.GetMakefile().AddDefinition(variable, value);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -8,34 +8,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cm_memory.hxx"
|
|
||||||
|
|
||||||
#include "cmCommand.h"
|
|
||||||
|
|
||||||
class cmExecutionStatus;
|
class cmExecutionStatus;
|
||||||
|
|
||||||
/** \class cmRemoveCommand
|
/**
|
||||||
* \brief remove command
|
* \brief remove command
|
||||||
*
|
*
|
||||||
* cmRemoveCommand implements the remove CMake command
|
* cmRemoveCommand implements the remove CMake command
|
||||||
*/
|
*/
|
||||||
class cmRemoveCommand : public cmCommand
|
bool cmRemoveCommand(std::vector<std::string> const& args,
|
||||||
{
|
cmExecutionStatus& status);
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* This is a virtual constructor for the command.
|
|
||||||
*/
|
|
||||||
std::unique_ptr<cmCommand> Clone() override
|
|
||||||
{
|
|
||||||
return cm::make_unique<cmRemoveCommand>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is called when the command is first encountered in
|
|
||||||
* the CMakeLists.txt file.
|
|
||||||
*/
|
|
||||||
bool InitialPass(std::vector<std::string> const& args,
|
|
||||||
cmExecutionStatus& status) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user