2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2001-01-18 16:20:24 +00:00
|
|
|
#ifndef cmCommand_h
|
|
|
|
#define cmCommand_h
|
2001-01-10 22:05:42 +00:00
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2017-04-11 19:42:35 +00:00
|
|
|
|
2016-10-25 18:35:04 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class cmExecutionStatus;
|
|
|
|
class cmMakefile;
|
|
|
|
struct cmListFileArgument;
|
2001-01-05 16:41:20 +00:00
|
|
|
|
2001-01-18 16:20:24 +00:00
|
|
|
/** \class cmCommand
|
|
|
|
* \brief Superclass for all commands in CMake.
|
2001-01-10 22:05:42 +00:00
|
|
|
*
|
2001-01-18 16:20:24 +00:00
|
|
|
* cmCommand is the base class for all commands in CMake. A command
|
|
|
|
* manifests as an entry in CMakeLists.txt and produces one or
|
|
|
|
* more makefile rules. Commands are associated with a particular
|
2012-08-13 17:42:58 +00:00
|
|
|
* makefile. This base class cmCommand defines the API for commands
|
|
|
|
* to support such features as enable/disable, inheritance,
|
2001-01-18 16:20:24 +00:00
|
|
|
* documentation, and construction.
|
2001-01-10 22:05:42 +00:00
|
|
|
*/
|
2016-10-22 22:45:08 +00:00
|
|
|
class cmCommand
|
2001-01-05 16:41:20 +00:00
|
|
|
{
|
2017-04-23 20:50:47 +00:00
|
|
|
CM_DISABLE_COPY(cmCommand)
|
|
|
|
|
2001-01-05 16:41:20 +00:00
|
|
|
public:
|
2001-01-10 22:05:42 +00:00
|
|
|
/**
|
2016-10-23 06:55:19 +00:00
|
|
|
* Construct the command. By default it has no makefile.
|
2001-01-10 22:05:42 +00:00
|
|
|
*/
|
2012-08-13 17:42:58 +00:00
|
|
|
cmCommand()
|
2017-08-22 21:42:36 +00:00
|
|
|
: Makefile(nullptr)
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
}
|
2001-01-10 22:05:42 +00:00
|
|
|
|
2001-02-23 15:40:13 +00:00
|
|
|
/**
|
|
|
|
* Need virtual destructor to destroy real command type.
|
|
|
|
*/
|
2016-10-22 22:45:08 +00:00
|
|
|
virtual ~cmCommand() {}
|
2012-08-13 17:42:58 +00:00
|
|
|
|
2001-01-10 22:05:42 +00:00
|
|
|
/**
|
|
|
|
* Specify the makefile.
|
|
|
|
*/
|
2016-05-16 14:34:04 +00:00
|
|
|
void SetMakefile(cmMakefile* m) { this->Makefile = m; }
|
2006-03-15 16:02:08 +00:00
|
|
|
cmMakefile* GetMakefile() { return this->Makefile; }
|
2001-01-10 22:05:42 +00:00
|
|
|
|
2002-12-11 23:13:33 +00:00
|
|
|
/**
|
|
|
|
* This is called by the cmMakefile when the command is first
|
|
|
|
* encountered in the CMakeLists.txt file. It expands the command's
|
|
|
|
* arguments and then invokes the InitialPass.
|
|
|
|
*/
|
2008-01-23 15:28:26 +00:00
|
|
|
virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
|
2016-10-19 22:29:18 +00:00
|
|
|
cmExecutionStatus& status);
|
2002-12-11 23:13:33 +00:00
|
|
|
|
2001-01-10 22:05:42 +00:00
|
|
|
/**
|
2001-01-18 16:20:24 +00:00
|
|
|
* This is called when the command is first encountered in
|
2001-01-10 22:05:42 +00:00
|
|
|
* the CMakeLists.txt file.
|
|
|
|
*/
|
2008-01-23 15:28:26 +00:00
|
|
|
virtual bool InitialPass(std::vector<std::string> const& args,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmExecutionStatus&) = 0;
|
2001-01-10 22:05:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called at the end after all the information
|
2001-01-18 16:20:24 +00:00
|
|
|
* specified by the command is accumulated. Most commands do
|
2001-02-19 20:13:48 +00:00
|
|
|
* not implement this method. At this point, reading and
|
|
|
|
* writing to the cache can be done.
|
2001-01-10 22:05:42 +00:00
|
|
|
*/
|
2014-04-03 19:35:22 +00:00
|
|
|
virtual void FinalPass() {}
|
2009-07-24 17:31:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Does this command have a final pass? Query after InitialPass.
|
|
|
|
*/
|
|
|
|
virtual bool HasFinalPass() const { return false; }
|
2012-08-13 17:42:58 +00:00
|
|
|
|
2001-01-10 22:05:42 +00:00
|
|
|
/**
|
2001-01-18 16:20:24 +00:00
|
|
|
* This is a virtual constructor for the command.
|
2001-01-10 22:05:42 +00:00
|
|
|
*/
|
2001-01-18 16:20:24 +00:00
|
|
|
virtual cmCommand* Clone() = 0;
|
2012-08-13 17:42:58 +00:00
|
|
|
|
2001-01-10 22:05:42 +00:00
|
|
|
/**
|
|
|
|
* Return the last error string.
|
|
|
|
*/
|
2016-10-19 22:29:18 +00:00
|
|
|
const char* GetError();
|
2001-01-10 22:05:42 +00:00
|
|
|
|
2005-06-15 19:51:39 +00:00
|
|
|
/**
|
|
|
|
* Set the error message
|
|
|
|
*/
|
2016-10-19 22:29:18 +00:00
|
|
|
void SetError(const std::string& e);
|
2005-06-15 19:51:39 +00:00
|
|
|
|
|
|
|
protected:
|
2006-03-15 16:02:08 +00:00
|
|
|
cmMakefile* Makefile;
|
2001-01-10 22:05:42 +00:00
|
|
|
|
2001-01-05 16:41:20 +00:00
|
|
|
private:
|
2006-03-15 16:02:08 +00:00
|
|
|
std::string Error;
|
2001-01-05 16:41:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|