cmake/Source/cmCommand.h

100 lines
2.4 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmCommand_h
#define cmCommand_h
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2017-07-20 19:35:53 +02:00
2017-04-14 19:02:05 +02:00
#include <string>
#include <vector>
2016-07-09 11:21:54 +02:00
2017-04-14 19:02:05 +02:00
class cmExecutionStatus;
class cmMakefile;
struct cmListFileArgument;
/** \class cmCommand
* \brief Superclass for all commands in CMake.
*
* 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
2013-03-16 19:13:01 +02:00
* makefile. This base class cmCommand defines the API for commands
* to support such features as enable/disable, inheritance,
* documentation, and construction.
*/
2017-04-14 19:02:05 +02:00
class cmCommand
{
2017-07-20 19:35:53 +02:00
CM_DISABLE_COPY(cmCommand)
public:
/**
2017-04-14 19:02:05 +02:00
* Construct the command. By default it has no makefile.
*/
2013-03-16 19:13:01 +02:00
cmCommand()
2018-01-26 17:06:56 +01:00
: Makefile(nullptr)
2016-07-09 11:21:54 +02:00
{
}
/**
* Need virtual destructor to destroy real command type.
*/
2017-04-14 19:02:05 +02:00
virtual ~cmCommand() {}
2013-03-16 19:13:01 +02:00
/**
* Specify the makefile.
*/
2016-07-09 11:21:54 +02:00
void SetMakefile(cmMakefile* m) { this->Makefile = m; }
cmMakefile* GetMakefile() { return this->Makefile; }
/**
* 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.
*/
virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
2017-04-14 19:02:05 +02:00
cmExecutionStatus& status);
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
2016-07-09 11:21:54 +02:00
cmExecutionStatus&) = 0;
/**
* This is called at the end after all the information
* specified by the command is accumulated. Most commands do
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
2015-04-27 22:25:09 +02:00
virtual void FinalPass() {}
2009-10-04 10:30:41 +03:00
/**
* Does this command have a final pass? Query after InitialPass.
*/
virtual bool HasFinalPass() const { return false; }
2013-03-16 19:13:01 +02:00
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone() = 0;
2013-03-16 19:13:01 +02:00
/**
* Return the last error string.
*/
2017-04-14 19:02:05 +02:00
const char* GetError();
/**
* Set the error message
*/
2017-04-14 19:02:05 +02:00
void SetError(const std::string& e);
protected:
cmMakefile* Makefile;
private:
std::string Error;
};
#endif