packaging: Initial packaging
[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         "If the <input> file is modified the build system will re-run CMake "
72         "to re-configure the file and generate the build system again."
73         "\n"
74         "This command replaces any variables in the input file referenced as "
75         "${VAR} or @VAR@ with their values as determined by CMake.  If a "
76         "variable is not defined, it will be replaced with nothing.  "
77         "If COPYONLY is specified, then no variable expansion will take "
78         "place.  If ESCAPE_QUOTES is specified then any substituted quotes "
79         "will be C-style escaped.  "
80         "The file will be configured with the current values of CMake "
81         "variables. If @ONLY is specified, only variables "
82         "of the form @VAR@ will be replaced and ${VAR} will be ignored.  "
83         "This is useful for configuring scripts that use ${VAR}."
84         "\n"
85         "Input file lines of the form \"#cmakedefine VAR ...\" "
86         "will be replaced with either \"#define VAR ...\" or "
87         "\"/* #undef VAR */\" depending on whether VAR is set in CMake to "
88         "any value not considered a false constant by the if() command. "
89         "(Content of \"...\", if any, is processed as above.) "
90         "Input file lines of the form \"#cmakedefine01 VAR\" "
91         "will be replaced with either \"#define VAR 1\" or "
92         "\"#define VAR 0\" similarly."
93         "\n"
94         "With NEWLINE_STYLE the line ending could be adjusted: \n"
95         "    'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n"
96         "COPYONLY must not be used with NEWLINE_STYLE.\n";
97     }
98
99   virtual void FinalPass();
100   virtual bool HasFinalPass() const { return !this->Immediate; }
101
102 private:
103   int ConfigureFile();
104
105   cmNewLineStyle NewLineStyle;
106
107   std::string InputFile;
108   std::string OutputFile;
109   bool CopyOnly;
110   bool EscapeQuotes;
111   bool Immediate;
112   bool AtOnly;
113 };
114
115
116
117 #endif