cmCPackGenerator.h 3.7 KB

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