1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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
15 #include "cmCommand.h"
17 class cmConfigureFileCommand : public cmCommand
20 cmTypeMacro(cmConfigureFileCommand, cmCommand);
22 virtual cmCommand* Clone()
24 return new cmConfigureFileCommand;
28 * This is called when the command is first encountered in
31 virtual bool InitialPass(std::vector<std::string> const& args,
32 cmExecutionStatus &status);
35 * The name of the command as specified in CMakeList.txt.
37 virtual const char* GetName() const { return "configure_file";}
40 * This determines if the command is invoked when in script mode.
42 virtual bool IsScriptable() const { return true; }
45 * Succinct documentation.
47 virtual const char* GetTerseDocumentation() const
49 return "Copy a file to another location and modify its contents.";
53 * Longer documentation.
55 virtual const char* GetFullDocumentation() const
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. "
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."
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}."
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."
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";
99 virtual void FinalPass();
100 virtual bool HasFinalPass() const { return !this->Immediate; }
105 cmNewLineStyle NewLineStyle;
107 std::string InputFile;
108 std::string OutputFile;