summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorGabor Bencze <b.gabor98@gmail.com>2019-07-25 17:24:45 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-20 18:42:19 (GMT)
commit6377efd154a385349f2e826c1388e1d768bfcbcb (patch)
treea41dcf4d7957011230c8972dba72bb9afbf0ff26 /Source
parent067d1fa9c0d887efb35b859230d743307f04fecd (diff)
downloadCMake-6377efd154a385349f2e826c1388e1d768bfcbcb.zip
CMake-6377efd154a385349f2e826c1388e1d768bfcbcb.tar.gz
CMake-6377efd154a385349f2e826c1388e1d768bfcbcb.tar.bz2
cmCommand refactor: cmGetFilenameComponentCommand
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx25
-rw-r--r--Source/cmGetFilenameComponentCommand.h26
3 files changed, 16 insertions, 37 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 2cce9b7..d401b25 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -139,7 +139,7 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("get_directory_property",
cmGetDirectoryPropertyCommand);
state->AddBuiltinCommand("get_filename_component",
- cm::make_unique<cmGetFilenameComponentCommand>());
+ cmGetFilenameComponentCommand);
state->AddBuiltinCommand("get_property",
cm::make_unique<cmGetPropertyCommand>());
state->AddBuiltinCommand("if", cmIfCommand);
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index d56af3d..7d91a75 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -2,26 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetFilenameComponentCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmGetFilenameComponentCommand
-bool cmGetFilenameComponentCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetFilenameComponentCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// Check and see if the value has been stored in the cache
// already, if so use that value
if (args.size() >= 4 && args.back() == "CACHE") {
- const char* cacheValue = this->Makefile->GetDefinition(args.front());
+ const char* cacheValue = status.GetMakefile().GetDefinition(args.front());
if (cacheValue && !cmIsNOTFOUND(cacheValue)) {
return true;
}
@@ -33,7 +32,7 @@ bool cmGetFilenameComponentCommand::InitialPass(
// Check the registry as the target application would view it.
cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
- if (this->Makefile->PlatformIs64Bit()) {
+ if (status.GetMakefile().PlatformIs64Bit()) {
view = cmSystemTools::KeyWOW64_64;
other_view = cmSystemTools::KeyWOW64_32;
}
@@ -97,7 +96,7 @@ bool cmGetFilenameComponentCommand::InitialPass(
// If the path given is relative, evaluate it relative to the
// current source directory unless the user passes a different
// base directory.
- std::string baseDir = this->Makefile->GetCurrentSourceDirectory();
+ std::string baseDir = status.GetMakefile().GetCurrentSourceDirectory();
for (unsigned int i = 3; i < args.size(); ++i) {
if (args[i] == "BASE_DIR") {
++i;
@@ -114,24 +113,24 @@ bool cmGetFilenameComponentCommand::InitialPass(
}
} else {
std::string err = "unknown component " + args[2];
- this->SetError(err);
+ status.SetError(err);
return false;
}
if (args.size() >= 4 && args.back() == "CACHE") {
if (!programArgs.empty() && !storeArgs.empty()) {
- this->Makefile->AddCacheDefinition(
+ status.GetMakefile().AddCacheDefinition(
storeArgs, programArgs.c_str(), "",
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
}
- this->Makefile->AddCacheDefinition(
+ status.GetMakefile().AddCacheDefinition(
args.front(), result.c_str(), "",
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
} else {
if (!programArgs.empty() && !storeArgs.empty()) {
- this->Makefile->AddDefinition(storeArgs, programArgs);
+ status.GetMakefile().AddDefinition(storeArgs, programArgs);
}
- this->Makefile->AddDefinition(args.front(), result);
+ status.GetMakefile().AddDefinition(args.front(), result);
}
return true;
diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h
index 1780b96..db5293b 100644
--- a/Source/cmGetFilenameComponentCommand.h
+++ b/Source/cmGetFilenameComponentCommand.h
@@ -8,35 +8,15 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmGetFilenameComponentCommand
+/**
* \brief Get a specific component of a filename.
*
* cmGetFilenameComponentCommand is a utility command used to get the path,
* name, extension or name without extension of a full filename.
*/
-class cmGetFilenameComponentCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmGetFilenameComponentCommand>();
- }
-
- /**
- * 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 cmGetFilenameComponentCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif