cmCPackGenerator.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCPackGenerator_h
  11. #define cmCPackGenerator_h
  12. #include "cmObject.h"
  13. #include <map>
  14. #include <vector>
  15. #include "cmCPackComponentGroup.h" // cmCPackComponent and friends
  16. // Forward declarations are insufficient since we use them in
  17. // std::map data members below...
  18. #define cmCPackTypeMacro(class, superclass) \
  19. cmTypeMacro(class, superclass); \
  20. static cmCPackGenerator* CreateGenerator() { return new class; }
  21. #define cmCPackLogger(logType, msg) \
  22. do { \
  23. cmOStringStream cmCPackLog_msg; \
  24. cmCPackLog_msg << msg; \
  25. this->Logger->Log(logType, __FILE__, __LINE__,\
  26. cmCPackLog_msg.str().c_str());\
  27. } while ( 0 )
  28. #ifdef cerr
  29. # undef cerr
  30. #endif
  31. #define cerr no_cerr_use_cmCPack_Log
  32. #ifdef cout
  33. # undef cout
  34. #endif
  35. #define cout no_cout_use_cmCPack_Log
  36. class cmMakefile;
  37. class cmCPackLog;
  38. /** \class cmCPackGenerator
  39. * \brief A superclass of all CPack Generators
  40. *
  41. */
  42. class cmCPackGenerator : public cmObject
  43. {
  44. public:
  45. cmTypeMacro(cmCPackGenerator, cmObject);
  46. /**
  47. * If verbose then more informaiton is printed out
  48. */
  49. void SetVerbose(bool val) { this->GeneratorVerbose = val; }
  50. /**
  51. * Do the actual processing. Subclass has to override it.
  52. * Return 0 if error.
  53. */
  54. virtual int DoPackage();
  55. /**
  56. * Initialize generator
  57. */
  58. int Initialize(const char* name, cmMakefile* mf);
  59. /**
  60. * Construct generator
  61. */
  62. cmCPackGenerator();
  63. virtual ~cmCPackGenerator();
  64. //! Set and get the options
  65. void SetOption(const char* op, const char* value);
  66. void SetOptionIfNotSet(const char* op, const char* value);
  67. const char* GetOption(const char* op);
  68. bool IsSet(const char* name) const;
  69. //! Set all the variables
  70. int SetCMakeRoot();
  71. //! Set the logger
  72. void SetLogger(cmCPackLog* log) { this->Logger = log; }
  73. //! Display verbose information via logger
  74. void DisplayVerboseOutput(const char* msg, float progress);
  75. bool ReadListFile(const char* moduleName);
  76. protected:
  77. int PrepareNames();
  78. int InstallProject();
  79. int CleanTemporaryDirectory();
  80. virtual const char* GetOutputExtension() { return ".cpack"; }
  81. virtual const char* GetOutputPostfix() { return 0; }
  82. virtual int CompressFiles(const char* outFileName, const char* toplevel,
  83. const std::vector<std::string>& files);
  84. virtual const char* GetInstallPath();
  85. virtual const char* GetPackagingInstallPrefix();
  86. virtual std::string FindTemplate(const char* name);
  87. virtual bool ConfigureFile(const char* inName, const char* outName,
  88. bool copyOnly = false);
  89. virtual bool ConfigureString(const std::string& input, std::string& output);
  90. virtual int InitializeInternal();
  91. //! Run install commands if specified
  92. virtual int InstallProjectViaInstallCommands(
  93. bool setDestDir, const char* tempInstallDirectory);
  94. virtual int InstallProjectViaInstallScript(
  95. bool setDestDir, const char* tempInstallDirectory);
  96. virtual int InstallProjectViaInstalledDirectories(
  97. bool setDestDir, const char* tempInstallDirectory);
  98. virtual int InstallProjectViaInstallCMakeProjects(
  99. bool setDestDir, const char* tempInstallDirectory);
  100. virtual bool SupportsComponentInstallation() const;
  101. virtual cmCPackInstallationType* GetInstallationType(const char *projectName,
  102. const char* name);
  103. virtual cmCPackComponent* GetComponent(const char *projectName,
  104. const char* name);
  105. virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName,
  106. const char* name);
  107. bool GeneratorVerbose;
  108. std::string Name;
  109. std::string InstallPath;
  110. std::string CPackSelf;
  111. std::string CMakeSelf;
  112. std::string CMakeRoot;
  113. std::map<std::string, cmCPackInstallationType> InstallationTypes;
  114. std::map<std::string, cmCPackComponent> Components;
  115. std::map<std::string, cmCPackComponentGroup> ComponentGroups;
  116. cmCPackLog* Logger;
  117. private:
  118. cmMakefile* MakefileMap;
  119. };
  120. #endif