~ubuntu-branches/ubuntu/intrepid/cmake/intrepid-backports

« back to all changes in this revision

Viewing changes to Source/cmMakeDepend.h

  • Committer: Bazaar Package Importer
  • Author(s): Maitland Bottoms
  • Date: 2002-02-14 18:36:25 UTC
  • Revision ID: james.westby@ubuntu.com-20020214183625-8m44isdas2k4l0f7
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Insight Segmentation & Registration Toolkit
 
4
  Module:    $RCSfile: cmMakeDepend.h,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2001/08/22 15:58:17 $
 
7
  Version:   $Revision: 1.13 $
 
8
 
 
9
Copyright (c) 2001 Insight Consortium
 
10
All rights reserved.
 
11
 
 
12
Redistribution and use in source and binary forms, with or without
 
13
modification, are permitted provided that the following conditions are met:
 
14
 
 
15
 * Redistributions of source code must retain the above copyright notice,
 
16
   this list of conditions and the following disclaimer.
 
17
 
 
18
 * Redistributions in binary form must reproduce the above copyright notice,
 
19
   this list of conditions and the following disclaimer in the documentation
 
20
   and/or other materials provided with the distribution.
 
21
 
 
22
 * The name of the Insight Consortium, nor the names of any consortium members,
 
23
   nor of any contributors, may be used to endorse or promote products derived
 
24
   from this software without specific prior written permission.
 
25
 
 
26
  * Modified source versions must be plainly marked as such, and must not be
 
27
    misrepresented as being the original software.
 
28
 
 
29
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
 
30
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
31
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
32
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
 
33
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
34
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
35
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
36
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
37
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
38
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
39
 
 
40
=========================================================================*/
 
41
#ifndef cmMakeDepend_h
 
42
#define cmMakeDepend_h
 
43
 
 
44
#include "cmMakefile.h"
 
45
#include "cmSourceFile.h"
 
46
#include "cmRegularExpression.h"
 
47
#include "cmStandardIncludes.h"
 
48
 
 
49
/** \class cmDependInformation
 
50
 * \brief Store dependency information for a single source file.
 
51
 *
 
52
 * This structure stores the depend information for a single source file.
 
53
 */
 
54
class cmDependInformation
 
55
{
 
56
public:
 
57
  /**
 
58
   * Construct with dependency generation marked not done; instance
 
59
   * not placed in cmMakefile's list.
 
60
   */
 
61
  cmDependInformation(): m_DependDone(false), m_cmSourceFile(0) {}
 
62
 
 
63
  /**
 
64
   * The set of files on which this one depends.
 
65
   */
 
66
  typedef std::set<cmDependInformation*> DependencySet;
 
67
  DependencySet m_DependencySet;
 
68
 
 
69
  /**
 
70
   * This flag indicates whether dependency checking has been
 
71
   * performed for this file.
 
72
   */
 
73
  bool m_DependDone;
 
74
 
 
75
  /**
 
76
   * If this object corresponds to a cmSourceFile instance, this points
 
77
   * to it.
 
78
   */
 
79
  const cmSourceFile *m_cmSourceFile;
 
80
  
 
81
  /**
 
82
   * Full path to this file.
 
83
   */
 
84
  std::string m_FullPath;
 
85
  
 
86
  /**
 
87
   * Name used to #include this file.
 
88
   */
 
89
  std::string m_IncludeName;
 
90
  
 
91
  /**
 
92
   * This method adds the dependencies of another file to this one.
 
93
   */
 
94
  void AddDependencies(cmDependInformation*);  
 
95
};
 
96
 
 
97
 
 
98
// cmMakeDepend is used to generate dependancy information for
 
99
// the classes in a makefile
 
100
class cmMakeDepend
 
101
{
 
102
public:
 
103
  /**
 
104
   * Construct the object with verbose turned off.
 
105
   */
 
106
  cmMakeDepend();
 
107
 
 
108
  /**
 
109
   * Destructor.
 
110
   */
 
111
  virtual ~cmMakeDepend();
 
112
  
 
113
  /** 
 
114
   * Set the makefile that is used as a source of classes.
 
115
   */
 
116
  virtual void SetMakefile(const cmMakefile* makefile); 
 
117
 
 
118
  /** 
 
119
   * Get the depend info struct for a source file
 
120
   */
 
121
  const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const;
 
122
 
 
123
  /**
 
124
   * Add a directory to the search path for include files.
 
125
   */
 
126
  virtual void AddSearchPath(const char*);
 
127
 
 
128
  /**
 
129
   * Generate dependencies for all the sources of all the targets
 
130
   * in the makefile.
 
131
   */
 
132
  void GenerateMakefileDependencies();
 
133
 
 
134
  /**
 
135
   * Generate dependencies for the file given.  Returns a pointer to
 
136
   * the cmDependInformation object for the file.
 
137
   */
 
138
  const cmDependInformation* FindDependencies(const char* file);
 
139
 
 
140
protected: 
 
141
  /**
 
142
   * Add a source file to the search path.
 
143
   */
 
144
  void AddFileToSearchPath(const char* filepath);
 
145
 
 
146
  /**
 
147
   * Compute the depend information for this class.
 
148
   */
 
149
  virtual void DependWalk(cmDependInformation* info);
 
150
  
 
151
  /**
 
152
   * Add a dependency.  Possibly walk it for more dependencies.
 
153
   */
 
154
  virtual void AddDependency(cmDependInformation* info, const char* file);
 
155
  
 
156
  /**
 
157
   * Fill in the given object with dependency information.  If the
 
158
   * information is already complete, nothing is done.
 
159
   */
 
160
  void GenerateDependInformation(cmDependInformation* info);
 
161
  
 
162
  /**
 
163
   * Get an instance of cmDependInformation corresponding to the given file
 
164
   * name.
 
165
   */
 
166
  cmDependInformation* GetDependInformation(const char* file);  
 
167
  
 
168
  /** 
 
169
   * Find the full path name for the given file name.
 
170
   * This uses the include directories.
 
171
   * TODO: Cache path conversions to reduce FileExists calls.
 
172
   */
 
173
  std::string FullPath(const char*);
 
174
 
 
175
  const cmMakefile* m_Makefile;
 
176
  bool m_Verbose;
 
177
  cmRegularExpression m_IncludeFileRegularExpression;
 
178
  cmRegularExpression m_ComplainFileRegularExpression;
 
179
  std::vector<std::string> m_IncludeDirectories;
 
180
  typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
 
181
  DependInformationMap m_DependInformationMap;
 
182
};
 
183
 
 
184
#endif