cmExecProgramCommand.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmExecProgramCommand_h
  4. #define cmExecProgramCommand_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <string>
  7. #include <vector>
  8. #include "cm_memory.hxx"
  9. #include "cmCommand.h"
  10. #include "cmProcessOutput.h"
  11. class cmExecutionStatus;
  12. /** \class cmExecProgramCommand
  13. * \brief Command that adds a target to the build system.
  14. *
  15. * cmExecProgramCommand adds an extra target to the build system.
  16. * This is useful when you would like to add special
  17. * targets like "install,", "clean," and so on.
  18. */
  19. class cmExecProgramCommand : public cmCommand
  20. {
  21. public:
  22. typedef cmProcessOutput::Encoding Encoding;
  23. /**
  24. * This is a virtual constructor for the command.
  25. */
  26. std::unique_ptr<cmCommand> Clone() override
  27. {
  28. return cm::make_unique<cmExecProgramCommand>();
  29. }
  30. /**
  31. * This is called when the command is first encountered in
  32. * the CMakeLists.txt file.
  33. */
  34. bool InitialPass(std::vector<std::string> const& args,
  35. cmExecutionStatus& status) override;
  36. private:
  37. static bool RunCommand(std::string command, std::string& output, int& retVal,
  38. const char* directory = nullptr, bool verbose = true,
  39. Encoding encoding = cmProcessOutput::Auto);
  40. };
  41. #endif