cmInstallGenerator.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. virtual bool HaveInstall();
  34. virtual void CheckCMP0082(bool& haveSubdirectoryInstall,
  35. bool& haveInstallAfterSubdirectory);
  36. void AddInstallRule(
  37. std::ostream& os, std::string const& dest, cmInstallType type,
  38. std::vector<std::string> const& files, bool optional = false,
  39. const char* permissions_file = nullptr,
  40. const char* permissions_dir = nullptr, const char* rename = nullptr,
  41. const char* literal_args = nullptr, Indent indent = Indent());
  42. /** Get the install destination as it should appear in the
  43. installation script. */
  44. std::string ConvertToAbsoluteDestination(std::string const& dest) const;
  45. /** Test if this generator installs something for a given configuration. */
  46. bool InstallsForConfig(const std::string& config);
  47. /** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
  48. static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
  49. virtual void Compute(cmLocalGenerator*) {}
  50. protected:
  51. void GenerateScript(std::ostream& os) override;
  52. std::string CreateComponentTest(const char* component,
  53. bool exclude_from_all);
  54. // Information shared by most generator types.
  55. std::string Destination;
  56. std::string Component;
  57. MessageLevel Message;
  58. bool ExcludeFromAll;
  59. };
  60. #endif