cmInstallGenerator.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <iosfwd>
  6. #include <string>
  7. #include <vector>
  8. #include "cmInstallType.h"
  9. #include "cmListFileCache.h"
  10. #include "cmScriptGenerator.h"
  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. public:
  20. enum MessageLevel
  21. {
  22. MessageDefault,
  23. MessageAlways,
  24. MessageLazy,
  25. MessageNever
  26. };
  27. cmInstallGenerator(std::string destination,
  28. std::vector<std::string> const& configurations,
  29. std::string component, MessageLevel message,
  30. bool exclude_from_all, cmListFileBacktrace backtrace);
  31. ~cmInstallGenerator() override;
  32. cmInstallGenerator(cmInstallGenerator const&) = delete;
  33. cmInstallGenerator& operator=(cmInstallGenerator const&) = delete;
  34. virtual bool HaveInstall();
  35. virtual void CheckCMP0082(bool& haveSubdirectoryInstall,
  36. bool& haveInstallAfterSubdirectory);
  37. void AddInstallRule(
  38. std::ostream& os, std::string const& dest, cmInstallType type,
  39. std::vector<std::string> const& files, bool optional = false,
  40. const char* permissions_file = nullptr,
  41. const char* permissions_dir = nullptr, const char* rename = nullptr,
  42. const char* literal_args = nullptr, Indent indent = Indent());
  43. /** Get the install destination as it should appear in the
  44. installation script. */
  45. std::string ConvertToAbsoluteDestination(std::string const& dest) const;
  46. /** Test if this generator installs something for a given configuration. */
  47. bool InstallsForConfig(const std::string& config);
  48. /** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
  49. static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
  50. virtual bool Compute(cmLocalGenerator*) { return true; }
  51. cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
  52. protected:
  53. void GenerateScript(std::ostream& os) override;
  54. std::string CreateComponentTest(const std::string& component,
  55. bool exclude_from_all);
  56. // Information shared by most generator types.
  57. std::string const Destination;
  58. std::string const Component;
  59. MessageLevel const Message;
  60. bool const ExcludeFromAll;
  61. cmListFileBacktrace const Backtrace;
  62. };