cmConfigureFileCommand.h 3.8 KB

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