diff options
author | Gabor Bencze <b.gabor98@gmail.com> | 2019-08-09 09:38:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-08-20 18:42:20 (GMT) |
commit | c33c52bb327d448868cff6aff6d83c786bc81e7e (patch) | |
tree | 821cc538d6e4ee13818477259d2f363634409c35 /Source | |
parent | b316d0d417761dc16d6d7b6ae41ac56b4509b949 (diff) | |
download | CMake-c33c52bb327d448868cff6aff6d83c786bc81e7e.zip CMake-c33c52bb327d448868cff6aff6d83c786bc81e7e.tar.gz CMake-c33c52bb327d448868cff6aff6d83c786bc81e7e.tar.bz2 |
cmCommand refactor: cmUnsetCommand
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCommands.cxx | 2 | ||||
-rw-r--r-- | Source/cmUnsetCommand.cxx | 17 | ||||
-rw-r--r-- | Source/cmUnsetCommand.h | 26 |
3 files changed, 12 insertions, 33 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 560c4cc..6b0af79 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -161,7 +161,7 @@ void GetScriptingCommands(cmState* state) cm::make_unique<cmSetPropertyCommand>()); state->AddBuiltinCommand("site_name", cmSiteNameCommand); state->AddBuiltinCommand("string", cm::make_unique<cmStringCommand>()); - state->AddBuiltinCommand("unset", cm::make_unique<cmUnsetCommand>()); + state->AddBuiltinCommand("unset", cmUnsetCommand); state->AddBuiltinCommand("while", cmWhileCommand); state->AddUnexpectedCommand( diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 3eb293a..3ba95e9 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -2,18 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmUnsetCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - // cmUnsetCommand -bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmUnsetCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) { if (args.empty() || args.size() > 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } @@ -31,20 +30,20 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, } // unset(VAR) if (args.size() == 1) { - this->Makefile->RemoveDefinition(variable); + status.GetMakefile().RemoveDefinition(variable); return true; } // unset(VAR CACHE) if ((args.size() == 2) && (args[1] == "CACHE")) { - this->Makefile->RemoveCacheDefinition(variable); + status.GetMakefile().RemoveCacheDefinition(variable); return true; } // unset(VAR PARENT_SCOPE) if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) { - this->Makefile->RaiseScope(variable, nullptr); + status.GetMakefile().RaiseScope(variable, nullptr); return true; } // ERROR: second argument isn't CACHE or PARENT_SCOPE - this->SetError("called with an invalid second argument"); + status.SetError("called with an invalid second argument"); return false; } diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 9b78d44..be4c166 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -8,34 +8,14 @@ #include <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmUnsetCommand +/** * \brief Unset a CMAKE variable * * cmUnsetCommand unsets or removes a variable. */ -class cmUnsetCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmUnsetCommand>(); - } - - /** - * 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; -}; +bool cmUnsetCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif |