1
/*=========================================================================
3
Program: CMake - Cross-Platform Makefile Generator
4
Module: $RCSfile: cmMacroCommand.h,v $
6
Date: $Date: 2004/04/29 21:41:33 $
7
Version: $Revision: 1.8 $
9
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12
This software is distributed WITHOUT ANY WARRANTY; without even
13
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
PURPOSE. See the above copyright notices for more information.
16
=========================================================================*/
17
#ifndef cmMacroCommand_h
18
#define cmMacroCommand_h
20
#include "cmCommand.h"
21
#include "cmFunctionBlocker.h"
23
/** \class cmMacroFunctionBlocker
24
* \brief subclass of function blocker
28
class cmMacroFunctionBlocker : public cmFunctionBlocker
31
cmMacroFunctionBlocker() {m_Executing = false;}
32
virtual ~cmMacroFunctionBlocker() {}
33
virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile &mf);
34
virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
35
virtual void ScopeEnded(cmMakefile &mf);
37
std::vector<std::string> m_Args;
38
std::vector<cmListFileFunction> m_Functions;
42
/** \class cmMacroCommand
43
* \brief starts an if block
45
* cmMacroCommand starts an if block
47
class cmMacroCommand : public cmCommand
51
* This is a virtual constructor for the command.
53
virtual cmCommand* Clone()
55
return new cmMacroCommand;
59
* This is called when the command is first encountered in
60
* the CMakeLists.txt file.
62
virtual bool InitialPass(std::vector<std::string> const& args);
65
* This determines if the command gets propagated down
66
* to makefiles located in subdirectories.
68
virtual bool IsInherited() {return true;}
71
* This determines if the command is invoked when in script mode.
73
virtual bool IsScriptable() { return true; }
76
* The name of the command as specified in CMakeList.txt.
78
virtual const char* GetName() { return "MACRO";}
81
* Succinct documentation.
83
virtual const char* GetTerseDocumentation()
85
return "Start recording a macro for later invocation as a command.";
91
virtual const char* GetFullDocumentation()
94
" MACRO(<name> [arg1 [arg2 [arg3 ...]]])\n"
95
" COMMAND1(ARGS ...)\n"
96
" COMMAND2(ARGS ...)\n"
99
"Define a macro named <name> that takes arguments named "
100
"arg1 arg2 arg3 (...). Commands listed after MACRO, "
101
"but before the matching ENDMACRO, are not invoked until the macro "
102
"is invoked. When it is invoked, the commands recorded in the "
103
"macro are first modified by replacing formal parameters (${arg1}) with "
104
"the arguments passed, and then invoked as normal commands. In "
105
"addition to referencing the formal parameters you can reference "
106
"the variable ARGC which will be set to the number of arguments "
107
"passed into the function as well as ARGV0 ARGV1 ARGV2 ... which "
108
"will have the actual values of the arguments passed in. This "
109
"fascilitates creating macros with optional arguments. Additionally "
110
"ARGV holds the list of all arguments given to the macro and ARGN "
111
"holds the list of argument pass the last expected argument.";
114
cmTypeMacro(cmMacroCommand, cmCommand);