cmExecuteProcessCommand.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 cmExecuteProcessCommand_h
  11. #define cmExecuteProcessCommand_h
  12. #include "cmCommand.h"
  13. /** \class cmExecuteProcessCommand
  14. * \brief Command that adds a target to the build system.
  15. *
  16. * cmExecuteProcessCommand is a CMake language interface to the KWSys
  17. * Process Execution implementation.
  18. */
  19. class cmExecuteProcessCommand : public cmCommand
  20. {
  21. public:
  22. /**
  23. * This is a virtual constructor for the command.
  24. */
  25. virtual cmCommand* Clone()
  26. {
  27. return new cmExecuteProcessCommand;
  28. }
  29. /**
  30. * This is called when the command is first encountered in
  31. * the CMakeLists.txt file.
  32. */
  33. virtual bool InitialPass(std::vector<std::string> const& args,
  34. cmExecutionStatus &status);
  35. /**
  36. * The name of the command as specified in CMakeList.txt.
  37. */
  38. virtual const char* GetName() const
  39. {return "execute_process";}
  40. /**
  41. * This determines if the command is invoked when in script mode.
  42. */
  43. virtual bool IsScriptable() const { return true; }
  44. /**
  45. * Succinct documentation.
  46. */
  47. virtual const char* GetTerseDocumentation() const
  48. {
  49. return "Execute one or more child processes.";
  50. }
  51. /**
  52. * More documentation.
  53. */
  54. virtual const char* GetFullDocumentation() const
  55. {
  56. return
  57. " execute_process(COMMAND <cmd1> [args1...]]\n"
  58. " [COMMAND <cmd2> [args2...] [...]]\n"
  59. " [WORKING_DIRECTORY <directory>]\n"
  60. " [TIMEOUT <seconds>]\n"
  61. " [RESULT_VARIABLE <variable>]\n"
  62. " [OUTPUT_VARIABLE <variable>]\n"
  63. " [ERROR_VARIABLE <variable>]\n"
  64. " [INPUT_FILE <file>]\n"
  65. " [OUTPUT_FILE <file>]\n"
  66. " [ERROR_FILE <file>]\n"
  67. " [OUTPUT_QUIET]\n"
  68. " [ERROR_QUIET]\n"
  69. " [OUTPUT_STRIP_TRAILING_WHITESPACE]\n"
  70. " [ERROR_STRIP_TRAILING_WHITESPACE])\n"
  71. "Runs the given sequence of one or more commands with the standard "
  72. "output of each process piped to the standard input of the next. "
  73. "A single standard error pipe is used for all processes. "
  74. "If WORKING_DIRECTORY is given the named directory will be set as "
  75. "the current working directory of the child processes. "
  76. "If TIMEOUT is given the child processes will be terminated if they "
  77. "do not finish in the specified number of seconds "
  78. "(fractions are allowed). "
  79. "If RESULT_VARIABLE is given the variable will be set to contain "
  80. "the result of running the processes. This will be an integer return "
  81. "code from the last child or a string describing an error condition. "
  82. "If OUTPUT_VARIABLE or ERROR_VARIABLE are given the variable named "
  83. "will be set with the contents of the standard output and standard "
  84. "error pipes respectively. If the same variable is named for both "
  85. "pipes their output will be merged in the order produced. "
  86. "If INPUT_FILE, OUTPUT_FILE, or ERROR_FILE is given the file named "
  87. "will be attached to the standard input of the first process, "
  88. "standard output of the last process, or standard error of all "
  89. "processes respectively. "
  90. "If OUTPUT_QUIET or ERROR_QUIET is given then the standard output "
  91. "or standard error results will be quietly ignored. "
  92. "If more than one OUTPUT_* or ERROR_* option is given for the same "
  93. "pipe the precedence is not specified. "
  94. "If no OUTPUT_* or ERROR_* options are given the output will be shared "
  95. "with the corresponding pipes of the CMake process itself.\n"
  96. "The execute_process command is a newer more powerful version of "
  97. "exec_program, but the old command has been kept for compatibility."
  98. ;
  99. }
  100. cmTypeMacro(cmExecuteProcessCommand, cmCommand);
  101. };
  102. #endif