mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 22:30:07 -05:00
cmCommand refactor: cmIncludeGuardCommand
This commit is contained in:
@@ -143,8 +143,7 @@ void GetScriptingCommands(cmState* state)
|
||||
state->AddBuiltinCommand("get_property", cmGetPropertyCommand);
|
||||
state->AddBuiltinCommand("if", cmIfCommand);
|
||||
state->AddBuiltinCommand("include", cmIncludeCommand);
|
||||
state->AddBuiltinCommand("include_guard",
|
||||
cm::make_unique<cmIncludeGuardCommand>());
|
||||
state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand);
|
||||
state->AddBuiltinCommand("list", cm::make_unique<cmListCommand>());
|
||||
state->AddBuiltinCommand("macro", cm::make_unique<cmMacroCommand>());
|
||||
state->AddBuiltinCommand("make_directory",
|
||||
|
||||
@@ -50,11 +50,11 @@ bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar)
|
||||
} // anonymous namespace
|
||||
|
||||
// cmIncludeGuardCommand
|
||||
bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
bool cmIncludeGuardCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.size() > 1) {
|
||||
this->SetError(
|
||||
status.SetError(
|
||||
"given an invalid number of arguments. The command takes at "
|
||||
"most 1 argument.");
|
||||
return false;
|
||||
@@ -69,15 +69,15 @@ bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args,
|
||||
} else if (arg == "GLOBAL") {
|
||||
scope = GLOBAL;
|
||||
} else {
|
||||
this->SetError("given an invalid scope: " + arg);
|
||||
status.SetError("given an invalid scope: " + arg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string includeGuardVar = GetIncludeGuardVariableName(
|
||||
this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
|
||||
status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE"));
|
||||
|
||||
cmMakefile* const mf = this->Makefile;
|
||||
cmMakefile* const mf = &status.GetMakefile();
|
||||
|
||||
switch (scope) {
|
||||
case VARIABLE:
|
||||
|
||||
@@ -8,35 +8,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmCommand.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
/** \class cmIncludeGuardCommand
|
||||
/**
|
||||
* \brief cmIncludeGuardCommand identical to C++ #pragma_once command
|
||||
* Can work in 3 modes: GLOBAL (works on global properties),
|
||||
* DIRECTORY(use directory property), VARIABLE(unnamed overload without
|
||||
* arguments) define an ordinary variable to be used as include guard checker
|
||||
*/
|
||||
class cmIncludeGuardCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
std::unique_ptr<cmCommand> Clone() override
|
||||
{
|
||||
return cm::make_unique<cmIncludeGuardCommand>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 cmIncludeGuardCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user