diff options
author | Gabor Bencze <b.gabor98@gmail.com> | 2019-08-04 17:08:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-08-20 18:42:20 (GMT) |
commit | b3aa789630c6411300080ec05d58e6cd9dcb7a2b (patch) | |
tree | 729ce3c5cc977ac1c50066e7a5e2e0be7e721571 /Source | |
parent | 2a9299782ece0e2c5f990fcab2162d141aedb833 (diff) | |
download | CMake-b3aa789630c6411300080ec05d58e6cd9dcb7a2b.zip CMake-b3aa789630c6411300080ec05d58e6cd9dcb7a2b.tar.gz CMake-b3aa789630c6411300080ec05d58e6cd9dcb7a2b.tar.bz2 |
cmCommand refactor: cmSetCommand
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCommands.cxx | 2 | ||||
-rw-r--r-- | Source/cmSetCommand.cxx | 29 | ||||
-rw-r--r-- | Source/cmSetCommand.h | 26 |
3 files changed, 18 insertions, 39 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index c23a9ca..da266c3 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -154,7 +154,7 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("cmake_parse_arguments", cmParseArgumentsCommand); state->AddBuiltinCommand("return", cmReturnCommand); state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand); - state->AddBuiltinCommand("set", cm::make_unique<cmSetCommand>()); + state->AddBuiltinCommand("set", cmSetCommand); state->AddBuiltinCommand("set_directory_properties", cm::make_unique<cmSetDirectoryPropertiesCommand>()); state->AddBuiltinCommand("set_property", diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 1a12785..8c3a4cb 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSetCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" @@ -10,14 +11,12 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - // cmSetCommand -bool cmSetCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmSetCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } @@ -45,7 +44,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, std::string m = "Only the first value argument is used when setting " "an environment variable. Argument '" + args[2] + "' and later are unused."; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, m); + status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, m); } return true; } @@ -59,13 +58,13 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, // SET (VAR) // Removes the definition of VAR. if (args.size() == 1) { - this->Makefile->RemoveDefinition(variable); + status.GetMakefile().RemoveDefinition(variable); return true; } // SET (VAR PARENT_SCOPE) // Removes the definition of VAR // in the parent scope. if (args.size() == 2 && args.back() == "PARENT_SCOPE") { - this->Makefile->RaiseScope(variable, nullptr); + status.GetMakefile().RaiseScope(variable, nullptr); return true; } @@ -106,7 +105,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, value = cmJoin(cmMakeRange(args).advance(1).retreat(ignoreLastArgs), ";"); if (parentScope) { - this->Makefile->RaiseScope(variable, value.c_str()); + status.GetMakefile().RaiseScope(variable, value.c_str()); return true; } @@ -116,7 +115,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, if ((args.back() == "CACHE") || (args.size() > 1 && args[args.size() - 2] == "CACHE") || (force && !cache)) { - this->SetError("given invalid arguments for CACHE mode."); + status.SetError("given invalid arguments for CACHE mode."); return false; } @@ -125,7 +124,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, if (!cmState::StringToCacheEntryType(args[cacheStart + 1].c_str(), type)) { std::string m = "implicitly converting '" + args[cacheStart + 1] + "' to 'STRING' type."; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, m); + status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, m); // Setting this may not be required, since it's // initialized as a string. Keeping this here to // ensure that the type is actually converting to a string. @@ -135,7 +134,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, } // see if this is already in the cache - cmState* state = this->Makefile->GetState(); + cmState* state = status.GetMakefile().GetState(); const char* existingValue = state->GetCacheEntryValue(variable); if (existingValue && (state->GetCacheEntryType(variable) != cmStateEnums::UNINITIALIZED)) { @@ -150,11 +149,11 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, // if it is meant to be in the cache then define it in the cache if (cache) { - this->Makefile->AddCacheDefinition(variable, value.c_str(), docstring, - type, force); + status.GetMakefile().AddCacheDefinition(variable, value.c_str(), docstring, + type, force); } else { // add the definition - this->Makefile->AddDefinition(variable, value); + status.GetMakefile().AddDefinition(variable, value); } return true; } diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 1c5a435..0973d33 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -8,34 +8,14 @@ #include <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmSetCommand +/** * \brief Set a CMAKE variable * * cmSetCommand sets a variable to a value with expansion. */ -class cmSetCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmSetCommand>(); - } - - /** - * 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 cmSetCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif |