cmCPackGenerator.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. 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 cmCPackGenerator_h
  14. #define cmCPackGenerator_h
  15. #include "cmObject.h"
  16. #include <map>
  17. #include <vector>
  18. #include "cmCPackComponentGroup.h" // cmCPackComponent and friends
  19. // Forward declarations are insufficient since we use them in
  20. // std::map data members below...
  21. #define cmCPackTypeMacro(class, superclass) \
  22. cmTypeMacro(class, superclass); \
  23. static cmCPackGenerator* CreateGenerator() { return new class; }
  24. #define cmCPackLogger(logType, msg) \
  25. do { \
  26. cmOStringStream cmCPackLog_msg; \
  27. cmCPackLog_msg << msg; \
  28. this->Logger->Log(logType, __FILE__, __LINE__,\
  29. cmCPackLog_msg.str().c_str());\
  30. } while ( 0 )
  31. #ifdef cerr
  32. # undef cerr
  33. #endif
  34. #define cerr no_cerr_use_cmCPack_Log
  35. #ifdef cout
  36. # undef cout
  37. #endif
  38. #define cout no_cout_use_cmCPack_Log
  39. class cmMakefile;
  40. class cmCPackLog;
  41. /** \class cmCPackGenerator
  42. * \brief A superclass of all CPack Generators
  43. *
  44. */
  45. class cmCPackGenerator : public cmObject
  46. {
  47. public:
  48. cmTypeMacro(cmCPackGenerator, cmObject);
  49. /**
  50. * If verbose then more informaiton is printed out
  51. */
  52. void SetVerbose(bool val) { this->GeneratorVerbose = val; }
  53. /**
  54. * Do the actual processing. Subclass has to override it.
  55. * Return 0 if error.
  56. */
  57. virtual int DoPackage();
  58. /**
  59. * Initialize generator
  60. */
  61. int Initialize(const char* name, cmMakefile* mf, const char* argv0);
  62. /**
  63. * Construct generator
  64. */
  65. cmCPackGenerator();
  66. virtual ~cmCPackGenerator();
  67. //! Set and get the options
  68. void SetOption(const char* op, const char* value);
  69. void SetOptionIfNotSet(const char* op, const char* value);
  70. const char* GetOption(const char* op);
  71. bool IsSet(const char* name) const;
  72. //! Set all the variables
  73. int FindRunningCMake(const char* arg0);
  74. //! Set the logger
  75. void SetLogger(cmCPackLog* log) { this->Logger = log; }
  76. //! Display verbose information via logger
  77. void DisplayVerboseOutput(const char* msg, float progress);
  78. bool ReadListFile(const char* moduleName);
  79. protected:
  80. int PrepareNames();
  81. int InstallProject();
  82. int CleanTemporaryDirectory();
  83. virtual const char* GetOutputExtension() { return ".cpack"; }
  84. virtual const char* GetOutputPostfix() { return 0; }
  85. virtual int CompressFiles(const char* outFileName, const char* toplevel,
  86. const std::vector<std::string>& files);
  87. virtual const char* GetInstallPath();
  88. virtual const char* GetPackagingInstallPrefix();
  89. virtual std::string FindTemplate(const char* name);
  90. virtual bool ConfigureFile(const char* inName, const char* outName,
  91. bool copyOnly = false);
  92. virtual bool ConfigureString(const std::string& input, std::string& output);
  93. virtual int InitializeInternal();
  94. //! Run install commands if specified
  95. virtual int InstallProjectViaInstallCommands(
  96. bool setDestDir, const char* tempInstallDirectory);
  97. virtual int InstallProjectViaInstallScript(
  98. bool setDestDir, const char* tempInstallDirectory);
  99. virtual int InstallProjectViaInstalledDirectories(
  100. bool setDestDir, const char* tempInstallDirectory);
  101. virtual int InstallProjectViaInstallCMakeProjects(
  102. bool setDestDir, const char* tempInstallDirectory);
  103. virtual bool SupportsComponentInstallation() const;
  104. virtual cmCPackInstallationType* GetInstallationType(const char *projectName, const char* name);
  105. virtual cmCPackComponent* GetComponent(const char *projectName, const char* name);
  106. virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, 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