summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor Bencze <b.gabor98@gmail.com>2019-08-04 17:13:14 +0200
committerBrad King <brad.king@kitware.com>2019-08-20 14:42:19 -0400
commit5b40a872dd2d50e2c72c76df79ce087403daa37d (patch)
tree83c30e9b3c202fefb383c4811a2d7640f6ba6a36
parente0b7ff4af2a8f5a2c2f746c0976cd22367212c8a (diff)
downloadcmake-5b40a872dd2d50e2c72c76df79ce087403daa37d.tar.gz
cmCommand refactor: cmMakeDirectoryCommand
-rw-r--r--Source/cmCommands.cxx3
-rw-r--r--Source/cmMakeDirectoryCommand.cxx13
-rw-r--r--Source/cmMakeDirectoryCommand.h26
3 files changed, 10 insertions, 32 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 285c48ed60..e50f1a0359 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -146,8 +146,7 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand);
state->AddBuiltinCommand("list", cmListCommand);
state->AddBuiltinCommand("macro", cmMacroCommand);
- state->AddBuiltinCommand("make_directory",
- cm::make_unique<cmMakeDirectoryCommand>());
+ state->AddBuiltinCommand("make_directory", cmMakeDirectoryCommand);
state->AddBuiltinCommand("mark_as_advanced",
cm::make_unique<cmMarkAsAdvancedCommand>());
state->AddBuiltinCommand("math", cm::make_unique<cmMathCommand>());
diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx
index aff4ca650f..cdde6f9904 100644
--- a/Source/cmMakeDirectoryCommand.cxx
+++ b/Source/cmMakeDirectoryCommand.cxx
@@ -2,23 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakeDirectoryCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmMakeDirectoryCommand
-bool cmMakeDirectoryCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMakeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 1) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- if (!this->Makefile->CanIWriteThisFile(args[0])) {
+ if (!status.GetMakefile().CanIWriteThisFile(args[0])) {
std::string e = "attempted to create a directory: " + args[0] +
" into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h
index b1fb49bbe7..2474383bb0 100644
--- a/Source/cmMakeDirectoryCommand.h
+++ b/Source/cmMakeDirectoryCommand.h
@@ -8,13 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmMakeDirectoryCommand
+/**
* \brief Specify auxiliary source code directories.
*
* cmMakeDirectoryCommand specifies source code directories
@@ -23,23 +19,7 @@ class cmExecutionStatus;
* A side effect of this command is to create a subdirectory in the build
* directory structure.
*/
-class cmMakeDirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmMakeDirectoryCommand>();
- }
-
- /**
- * 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 cmMakeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif