cmCPackGenericGenerator.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. protected:
  71. int PrepareNames();
  72. int InstallProject();
  73. virtual const char* GetOutputExtension() { return "cpack"; }
  74. virtual const char* GetOutputPostfix() { return 0; }
  75. virtual int CompressFiles(const char* outFileName, const char* toplevel,
  76. const std::vector<std::string>& files);
  77. virtual const char* GetInstallPath();
  78. virtual const char* GetInstallPrefix() { return "/"; }
  79. virtual std::string FindTemplate(const char* name);
  80. virtual bool ConfigureFile(const char* inName, const char* outName);
  81. virtual bool ConfigureString(const std::string& input, std::string& output);
  82. virtual int InitializeInternal();
  83. bool GeneratorVerbose;
  84. std::string Name;
  85. std::string InstallPath;
  86. std::string CPackSelf;
  87. std::string CMakeSelf;
  88. std::string CMakeRoot;
  89. cmCPackLog* Logger;
  90. private:
  91. cmMakefile* MakefileMap;
  92. };
  93. #endif