cmInstallGenerator.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmInstallGenerator_h
  14. #define cmInstallGenerator_h
  15. #include "cmStandardIncludes.h"
  16. class cmLocalGenerator;
  17. class cmInstallGeneratorIndent
  18. {
  19. public:
  20. cmInstallGeneratorIndent(): Level(0) {}
  21. cmInstallGeneratorIndent(int level): Level(level) {}
  22. void Write(std::ostream& os) const
  23. {
  24. for(int i=0; i < this->Level; ++i)
  25. {
  26. os << " ";
  27. }
  28. }
  29. cmInstallGeneratorIndent Next(int step = 2) const
  30. {
  31. return cmInstallGeneratorIndent(this->Level + step);
  32. }
  33. private:
  34. int Level;
  35. };
  36. inline std::ostream& operator<<(std::ostream& os,
  37. cmInstallGeneratorIndent const& indent)
  38. {
  39. indent.Write(os);
  40. return os;
  41. }
  42. /** \class cmInstallGenerator
  43. * \brief Support class for generating install scripts.
  44. *
  45. */
  46. class cmInstallGenerator
  47. {
  48. public:
  49. cmInstallGenerator(const char* destination,
  50. std::vector<std::string> const& configurations,
  51. const char* component);
  52. virtual ~cmInstallGenerator();
  53. void Generate(std::ostream& os, const char* config,
  54. std::vector<std::string> const& configurationTypes);
  55. void AddInstallRule(
  56. std::ostream& os, int type,
  57. std::vector<std::string> const& files,
  58. bool optional = false,
  59. const char* properties = 0,
  60. const char* permissions_file = 0,
  61. const char* permissions_dir = 0,
  62. const char* rename = 0,
  63. const char* literal_args = 0,
  64. cmInstallGeneratorIndent const& indent = cmInstallGeneratorIndent()
  65. );
  66. const char* GetDestination() const
  67. { return this->Destination.c_str(); }
  68. const std::vector<std::string>& GetConfigurations() const
  69. { return this->Configurations; }
  70. /** Get the install destination as it should appear in the
  71. installation script. */
  72. std::string GetInstallDestination() const;
  73. /** Test if this generator installs something for a given configuration. */
  74. bool InstallsForConfig(const char*);
  75. protected:
  76. typedef cmInstallGeneratorIndent Indent;
  77. virtual void GenerateScript(std::ostream& os);
  78. virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
  79. virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
  80. std::string CreateConfigTest(const char* config);
  81. std::string CreateConfigTest(std::vector<std::string> const& configs);
  82. std::string CreateComponentTest(const char* component);
  83. // Information shared by most generator types.
  84. std::string Destination;
  85. std::vector<std::string> const Configurations;
  86. std::string Component;
  87. // Information used during generation.
  88. const char* ConfigurationName;
  89. std::vector<std::string> const* ConfigurationTypes;
  90. };
  91. #endif