cmCPackGenerator.h 4.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Kitware, Inc. All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

Bill Hoffman's avatar
Bill Hoffman committed
18
19
#ifndef cmCPackGenerator_h
#define cmCPackGenerator_h
20
21

#include "cmObject.h"
22
23
24
25
26
27
#include <map>
#include <vector>

#include "cmCPackComponentGroup.h" // cmCPackComponent and friends
  // Forward declarations are insufficient since we use them in
  // std::map data members below...
28
29
30

#define cmCPackTypeMacro(class, superclass) \
  cmTypeMacro(class, superclass); \
Bill Hoffman's avatar
Bill Hoffman committed
31
  static cmCPackGenerator* CreateGenerator() { return new class; }
32

33
34
#define cmCPackLogger(logType, msg) \
  do { \
Andy Cedilnik's avatar
Andy Cedilnik committed
35
36
37
38
    cmOStringStream cmCPackLog_msg; \
    cmCPackLog_msg << msg; \
    this->Logger->Log(logType, __FILE__, __LINE__,\
                      cmCPackLog_msg.str().c_str());\
39
40
41
42
43
44
45
46
47
48
49
50
  } while ( 0 )

#ifdef cerr
#  undef cerr
#endif
#define cerr no_cerr_use_cmCPack_Log

#ifdef cout
#  undef cout
#endif
#define cout no_cout_use_cmCPack_Log

51
class cmMakefile;
52
class cmCPackLog;
53

Bill Hoffman's avatar
Bill Hoffman committed
54
/** \class cmCPackGenerator
55
56
57
 * \brief A superclass of all CPack Generators
 *
 */
Bill Hoffman's avatar
Bill Hoffman committed
58
class cmCPackGenerator : public cmObject
59
60
{
public:
Bill Hoffman's avatar
Bill Hoffman committed
61
  cmTypeMacro(cmCPackGenerator, cmObject);
62
63
64
  /**
   * If verbose then more informaiton is printed out
   */
Andy Cedilnik's avatar
Andy Cedilnik committed
65
  void SetVerbose(bool val) { this->GeneratorVerbose = val; }
66
67
68
69
70

  /**
   * Do the actual processing. Subclass has to override it.
   * Return 0 if error.
   */
71
  virtual int DoPackage();
72
73
74
75

  /**
   * Initialize generator
   */
76
  int Initialize(const char* name, cmMakefile* mf);
77
78
79
80

  /**
   * Construct generator
   */
Bill Hoffman's avatar
Bill Hoffman committed
81
82
  cmCPackGenerator();
  virtual ~cmCPackGenerator();
83
84
85

  //! Set and get the options
  void SetOption(const char* op, const char* value);
86
  void SetOptionIfNotSet(const char* op, const char* value);
87
  const char* GetOption(const char* op);
Alexander Neundorf's avatar
   
Alexander Neundorf committed
88
  bool IsSet(const char* name) const;
89
90

  //! Set all the variables
91
  int SetCMakeRoot();
92

93
  //! Set the logger
Andy Cedilnik's avatar
Andy Cedilnik committed
94
  void SetLogger(cmCPackLog* log) { this->Logger = log; }
95

96
97
  //! Display verbose information via logger
  void DisplayVerboseOutput(const char* msg, float progress);
Alexander Neundorf's avatar
   
Alexander Neundorf committed
98
99
  
  bool ReadListFile(const char* moduleName);
100

101
102
103
protected:
  int PrepareNames();
  int InstallProject();
104
  int CleanTemporaryDirectory();
105
  virtual const char* GetOutputExtension() { return ".cpack"; }
106
107
108
109
  virtual const char* GetOutputPostfix() { return 0; }
  virtual int CompressFiles(const char* outFileName, const char* toplevel,
    const std::vector<std::string>& files);
  virtual const char* GetInstallPath();
110
  virtual const char* GetPackagingInstallPrefix();
111
112

  virtual std::string FindTemplate(const char* name);
Andy Cedilnik's avatar
Andy Cedilnik committed
113
114
  virtual bool ConfigureFile(const char* inName, const char* outName,
    bool copyOnly = false);
115
  virtual bool ConfigureString(const std::string& input, std::string& output);
116
  virtual int InitializeInternal();
117

118
119
120

  //! Run install commands if specified
  virtual int InstallProjectViaInstallCommands(
121
    bool setDestDir, const char* tempInstallDirectory);
122
  virtual int InstallProjectViaInstallScript(
123
    bool setDestDir, const char* tempInstallDirectory);
124
  virtual int InstallProjectViaInstalledDirectories(
125
    bool setDestDir, const char* tempInstallDirectory);
126
  virtual int InstallProjectViaInstallCMakeProjects(
127
    bool setDestDir, const char* tempInstallDirectory);
128

129
130
131
132
133
  virtual bool SupportsComponentInstallation() const;
  virtual cmCPackInstallationType* GetInstallationType(const char *projectName, const char* name);
  virtual cmCPackComponent* GetComponent(const char *projectName, const char* name);
  virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, const char* name);

Andy Cedilnik's avatar
Andy Cedilnik committed
134
135
  bool GeneratorVerbose;
  std::string Name;
136

Andy Cedilnik's avatar
Andy Cedilnik committed
137
  std::string InstallPath;
138

Andy Cedilnik's avatar
Andy Cedilnik committed
139
140
141
  std::string CPackSelf;
  std::string CMakeSelf;
  std::string CMakeRoot;
142

143
144
145
146
  std::map<std::string, cmCPackInstallationType> InstallationTypes;
  std::map<std::string, cmCPackComponent> Components;
  std::map<std::string, cmCPackComponentGroup> ComponentGroups;

Andy Cedilnik's avatar
Andy Cedilnik committed
147
  cmCPackLog* Logger;
Alexander Neundorf's avatar
   
Alexander Neundorf committed
148
149
private:
  cmMakefile* MakefileMap;
150
151
152
};

#endif