cmCPackGenericGenerator.h 3.8 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 cmCPackGenericGenerator_h
  14. #define cmCPackGenericGenerator_h
  15. #include "cmObject.h"
  16. #define cmCPackTypeMacro(class, superclass) \
  17. cmTypeMacro(class, superclass); \
  18. static cmCPackGenericGenerator* 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 cmCPackGenericGenerator
  37. * \brief A superclass of all CPack Generators
  38. *
  39. */
  40. class cmCPackGenericGenerator : public cmObject
  41. {
  42. public:
  43. cmTypeMacro(cmCPackGenericGenerator, 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 ProcessGenerator();
  53. /**
  54. * Initialize generator
  55. */
  56. int Initialize(const char* name, cmMakefile* mf, const char* argv0);
  57. /**
  58. * Construct generator
  59. */
  60. cmCPackGenericGenerator();
  61. virtual ~cmCPackGenericGenerator();
  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. //! Set all the variables
  67. int FindRunningCMake(const char* arg0);
  68. //! Set the logger
  69. void SetLogger(cmCPackLog* log) { this->Logger = log; }
  70. //! Display verbose information via logger
  71. void DisplayVerboseOutput(const char* msg, float progress);
  72. protected:
  73. int PrepareNames();
  74. int InstallProject();
  75. int CleanTemporaryDirectory();
  76. virtual const char* GetOutputExtension() { return ".cpack"; }
  77. virtual const char* GetOutputPostfix() { return 0; }
  78. virtual int CompressFiles(const char* outFileName, const char* toplevel,
  79. const std::vector<std::string>& files);
  80. virtual const char* GetInstallPath();
  81. virtual const char* GetInstallPrefix() { return "/"; }
  82. virtual const char* GetTemporaryInstallDirectoryPostfix() { return ""; }
  83. virtual std::string FindTemplate(const char* name);
  84. virtual bool ConfigureFile(const char* inName, const char* outName,
  85. bool copyOnly = false);
  86. virtual bool ConfigureString(const std::string& input, std::string& output);
  87. virtual int InitializeInternal();
  88. //! Run install commands if specified
  89. virtual int InstallProjectViaInstallCommands(
  90. bool movable, const char* tempInstallDirectory);
  91. virtual int InstallProjectViaInstallScript(
  92. bool movable, const char* tempInstallDirectory);
  93. virtual int InstallProjectViaInstalledDirectories(
  94. bool movable, const char* tempInstallDirectory);
  95. virtual int InstallProjectViaInstallCMakeProjects(
  96. bool movable, const char* tempInstallDirectory);
  97. bool GeneratorVerbose;
  98. std::string Name;
  99. std::string InstallPath;
  100. std::string CPackSelf;
  101. std::string CMakeSelf;
  102. std::string CMakeRoot;
  103. cmCPackLog* Logger;
  104. private:
  105. cmMakefile* MakefileMap;
  106. };
  107. #endif