cmInstallGenerator.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 cmInstallGenerator_h
  4. #define cmInstallGenerator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmInstallType.h"
  7. #include "cmScriptGenerator.h"
  8. #include <iosfwd>
  9. #include <string>
  10. #include <vector>
  11. class cmLocalGenerator;
  12. class cmMakefile;
  13. /** \class cmInstallGenerator
  14. * \brief Support class for generating install scripts.
  15. *
  16. */
  17. class cmInstallGenerator : public cmScriptGenerator
  18. {
  19. CM_DISABLE_COPY(cmInstallGenerator)
  20. public:
  21. enum MessageLevel
  22. {
  23. MessageDefault,
  24. MessageAlways,
  25. MessageLazy,
  26. MessageNever
  27. };
  28. cmInstallGenerator(const char* destination,
  29. std::vector<std::string> const& configurations,
  30. const char* component, MessageLevel message,
  31. bool exclude_from_all);
  32. ~cmInstallGenerator() override;
  33. void AddInstallRule(
  34. std::ostream& os, std::string const& dest, cmInstallType type,
  35. std::vector<std::string> const& files, bool optional = false,
  36. const char* permissions_file = nullptr,
  37. const char* permissions_dir = nullptr, const char* rename = nullptr,
  38. const char* literal_args = nullptr, Indent indent = Indent());
  39. /** Get the install destination as it should appear in the
  40. installation script. */
  41. std::string ConvertToAbsoluteDestination(std::string const& dest) const;
  42. /** Test if this generator installs something for a given configuration. */
  43. bool InstallsForConfig(const std::string& config);
  44. /** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
  45. static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
  46. virtual void Compute(cmLocalGenerator*) {}
  47. protected:
  48. void GenerateScript(std::ostream& os) override;
  49. std::string CreateComponentTest(const char* component,
  50. bool exclude_from_all);
  51. // Information shared by most generator types.
  52. std::string Destination;
  53. std::string Component;
  54. MessageLevel Message;
  55. bool ExcludeFromAll;
  56. };
  57. #endif