Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmConfigureFileCommand.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmConfigureFileCommand_h
13 #define cmConfigureFileCommand_h
14
15 #include "cmCommand.h"
16
17 class cmConfigureFileCommand : public cmCommand
18 {
19 public:
20   cmTypeMacro(cmConfigureFileCommand, cmCommand);
21
22   virtual cmCommand* Clone() 
23     {
24       return new cmConfigureFileCommand;
25     }
26
27   /**
28    * This is called when the command is first encountered in
29    * the input file.
30    */
31   virtual bool InitialPass(std::vector<std::string> const& args,
32                            cmExecutionStatus &status);
33
34   /**
35    * The name of the command as specified in CMakeList.txt.
36    */
37   virtual const char* GetName() const { return "configure_file";}
38
39   /**
40    * This determines if the command is invoked when in script mode.
41    */
42   virtual bool IsScriptable() const { return true; }
43
44   /**
45    * Succinct documentation.
46    */
47   virtual const char* GetTerseDocumentation() const
48     {
49     return "Copy a file to another location and modify its contents.";
50     }
51   
52   /**
53    * Longer documentation.
54    */
55   virtual const char* GetFullDocumentation() const
56     {
57       return
58         "  configure_file(<input> <output>\n"
59         "                 [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n"
60         "                 [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n"
61         "Copies a file <input> to file <output> and substitutes variable "
62         "values referenced in the file content.  "
63         "If <input> is a relative path it is evaluated with respect to "
64         "the current source directory.  "
65         "The <input> must be a file, not a directory.  "
66         "If <output> is a relative path it is evaluated with respect to "
67         "the current binary directory.  "
68         "If <output> names an existing directory the input file is placed "
69         "in that directory with its original name.  "
70         "\n"
71         "This command replaces any variables in the input file referenced as "
72         "${VAR} or @VAR@ with their values as determined by CMake.  If a "
73         "variable is not defined, it will be replaced with nothing.  "
74         "If COPYONLY is specified, then no variable expansion will take "
75         "place.  If ESCAPE_QUOTES is specified then any substituted quotes "
76         "will be C-style escaped.  "
77         "The file will be configured with the current values of CMake "
78         "variables. If @ONLY is specified, only variables "
79         "of the form @VAR@ will be replaces and ${VAR} will be ignored.  "
80         "This is useful for configuring scripts that use ${VAR}. "
81         "Any occurrences of #cmakedefine VAR will be replaced with "
82         "either #define VAR or /* #undef VAR */ depending on "
83         "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR "
84         "will be replaced with either #define VAR 1 or #define VAR 0 "
85         "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n"
86         "With NEWLINE_STYLE the line ending could be adjusted: \n"
87         "    'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n"
88         "COPYONLY must not be used with NEWLINE_STYLE.\n";
89     }
90
91   virtual void FinalPass();
92   virtual bool HasFinalPass() const { return !this->Immediate; }
93
94 private:
95   int ConfigureFile();
96   
97   cmNewLineStyle NewLineStyle;
98
99   std::string InputFile;
100   std::string OutputFile;
101   bool CopyOnly;
102   bool EscapeQuotes;
103   bool Immediate;
104   bool AtOnly;
105 };
106
107
108
109 #endif