cmConfigureFileCommand.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. "Copies a file <input> to file <output> and substitutes variable "
  51. "values referenced in the file content. "
  52. "If <input> is a relative path it is evaluated with respect to "
  53. "the current source directory. "
  54. "The <input> must be a file, not a directory. "
  55. "If <output> is a relative path it is evaluated with respect to "
  56. "the current binary directory. "
  57. "If <output> names an existing directory the input file is placed "
  58. "in that directory with its original name. "
  59. "\n"
  60. "This command replaces any variables in the input file referenced as "
  61. "${VAR} or @VAR@ with their values as determined by CMake. If a "
  62. "variable is not defined, it will be replaced with nothing. "
  63. "If COPYONLY is specified, then no variable expansion will take "
  64. "place. If ESCAPE_QUOTES is specified then any substituted quotes "
  65. "will be C-style escaped. "
  66. "The file will be configured with the current values of CMake "
  67. "variables. If @ONLY is specified, only variables "
  68. "of the form @VAR@ will be replaces and ${VAR} will be ignored. "
  69. "This is useful for configuring scripts that use ${VAR}. "
  70. "Any occurrences of #cmakedefine VAR will be replaced with "
  71. "either #define VAR or /* #undef VAR */ depending on "
  72. "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR "
  73. "will be replaced with either #define VAR 1 or #define VAR 0 "
  74. "depending on whether VAR evaluates to TRUE or FALSE in CMake";
  75. }
  76. virtual void FinalPass();
  77. virtual bool HasFinalPass() const { return !this->Immediate; }
  78. private:
  79. int ConfigureFile();
  80. std::string InputFile;
  81. std::string OutputFile;
  82. bool CopyOnly;
  83. bool EscapeQuotes;
  84. bool Immediate;
  85. bool AtOnly;
  86. };
  87. #endif