cmInstallGenerator.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. std::string const& GetComponent() const { return this->Component; }
  52. bool GetExcludeFromAll() const { return this->ExcludeFromAll; }
  53. cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
  54. protected:
  55. void GenerateScript(std::ostream& os) override;
  56. std::string CreateComponentTest(const std::string& component,
  57. bool exclude_from_all);
  58. // Information shared by most generator types.
  59. std::string const Destination;
  60. std::string const Component;
  61. MessageLevel const Message;
  62. bool const ExcludeFromAll;
  63. cmListFileBacktrace const Backtrace;
  64. };