cmInstallGenerator.h 2.8 KB

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