diff options
Diffstat (limited to 'Source/cmCommand.h')
-rw-r--r-- | Source/cmCommand.h | 95 |
1 files changed, 19 insertions, 76 deletions
diff --git a/Source/cmCommand.h b/Source/cmCommand.h index d8e337d..d9fd5a2 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -3,11 +3,16 @@ #ifndef cmCommand_h #define cmCommand_h -#include "cmObject.h" +#include <cmConfigure.h> +#include <string> +#include <vector> #include "cmCommandArgumentsHelper.h" -#include "cmListFileCache.h" -#include "cmMakefile.h" +#include "cmPolicies.h" + +class cmExecutionStatus; +class cmMakefile; +struct cmListFileArgument; /** \class cmCommand * \brief Superclass for all commands in CMake. @@ -19,24 +24,21 @@ * to support such features as enable/disable, inheritance, * documentation, and construction. */ -class cmCommand : public cmObject +class cmCommand { public: - cmTypeMacro(cmCommand, cmObject); - /** - * Construct the command. By default it is enabled with no makefile. + * Construct the command. By default it has no makefile. */ cmCommand() + : Makefile(CM_NULLPTR) { - this->Makefile = CM_NULLPTR; - this->Enabled = true; } /** * Need virtual destructor to destroy real command type. */ - ~cmCommand() CM_OVERRIDE {} + virtual ~cmCommand() {} /** * Specify the makefile. @@ -50,16 +52,7 @@ public: * arguments and then invokes the InitialPass. */ virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args, - cmExecutionStatus& status) - { - std::vector<std::string> expandedArguments; - if (!this->Makefile->ExpandArguments(args, expandedArguments)) { - // There was an error expanding arguments. It was already - // reported, so we can skip this command without error. - return true; - } - return this->InitialPass(expandedArguments, status); - } + cmExecutionStatus& status); /** * This is called when the command is first encountered in @@ -92,12 +85,10 @@ public: virtual bool IsScriptable() const { return false; } /** - * This is used to avoid including this command - * in documentation. This is mainly used by - * cmMacroHelperCommand and cmFunctionHelperCommand - * which cannot provide appropriate documentation. + * This determines if the command is defined in a cmake script. + * It is the case for cmMacroHelperCommand and cmFunctionHelperCommand. */ - virtual bool ShouldAppearInDocumentation() const { return true; } + virtual bool IsUserDefined() const { return false; } /** * The name of the command as specified in CMakeList.txt. @@ -105,71 +96,23 @@ public: virtual std::string GetName() const = 0; /** - * Enable the command. - */ - void EnabledOn() { this->Enabled = true; } - - /** - * Disable the command. - */ - void EnabledOff() { this->Enabled = false; } - - /** - * Query whether the command is enabled. - */ - bool GetEnabled() const { return this->Enabled; } - - /** - * Disable or enable the command. - */ - void SetEnabled(bool enabled) { this->Enabled = enabled; } - - /** * Return the last error string. */ - const char* GetError() - { - if (this->Error.empty()) { - this->Error = this->GetName(); - this->Error += " unknown error."; - } - return this->Error.c_str(); - } + const char* GetError(); /** * Set the error message */ - void SetError(const std::string& e) - { - this->Error = this->GetName(); - this->Error += " "; - this->Error += e; - } + void SetError(const std::string& e); /** Check if the command is disallowed by a policy. */ - bool Disallowed(cmPolicies::PolicyID pol, const char* e) - { - switch (this->Makefile->GetPolicyStatus(pol)) { - case cmPolicies::WARN: - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - cmPolicies::GetPolicyWarning(pol)); - case cmPolicies::OLD: - return false; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e); - break; - } - return true; - } + bool Disallowed(cmPolicies::PolicyID pol, const char* e); protected: cmMakefile* Makefile; cmCommandArgumentsHelper Helper; private: - bool Enabled; std::string Error; }; |