ENH: Return utility target after creation
[cmake.git] / Source / cmDepends.h
blob1cd63a777398e6b436da4c72bf2e01dda7061be0
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDepends.h,v $
5 Language: C++
6 Date: $Date: 2008-05-08 14:09:14 $
7 Version: $Revision: 1.15 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmDepends_h
18 #define cmDepends_h
20 #include "cmStandardIncludes.h"
22 class cmFileTimeComparison;
23 class cmLocalGenerator;
25 /** \class cmDepends
26 * \brief Dependency scanner superclass.
28 * This class is responsible for maintaining a .depends.make file in
29 * the build tree corresponding to an object file. Subclasses help it
30 * maintain dependencies for particular languages.
32 class cmDepends
34 public:
35 /** Instances need to know the build directory name and the relative
36 path from the build directory to the target file. */
37 cmDepends(cmLocalGenerator* lg=0, const char* targetDir="");
39 /** at what level will the compile be done from */
40 void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;};
42 /** Set the local generator for the directory in which we are
43 scanning dependencies. This is not a full local generator; it
44 has been setup to do relative path conversions for the current
45 directory. */
46 void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
48 /** Set the specific language to be scanned. */
49 void SetLanguage(const char* lang) { this->Language = lang; }
51 /** Set the target build directory. */
52 void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
54 /** should this be verbose in its output */
55 void SetVerbose(bool verb) { this->Verbose = verb; }
57 /** Virtual destructor to cleanup subclasses properly. */
58 virtual ~cmDepends();
60 /** Write dependencies for the target file. */
61 bool Write(std::ostream &makeDepends, std::ostream &internalDepends);
63 /** Check dependencies for the target file. Returns true if
64 dependencies are okay and false if they must be generated. If
65 they must be generated Clear has already been called to wipe out
66 the old dependencies. */
67 bool Check(const char *makeFile, const char* internalFile);
69 /** Clear dependencies for the target file so they will be regenerated. */
70 void Clear(const char *file);
72 /** Set the file comparison object */
73 void SetFileComparison(cmFileTimeComparison* fc) {
74 this->FileComparison = fc; }
76 protected:
78 // Write dependencies for the target file to the given stream.
79 // Return true for success and false for failure.
80 virtual bool WriteDependencies(const char *src, const char* obj,
81 std::ostream& makeDepends, std::ostream& internalDepends);
83 // Check dependencies for the target file in the given stream.
84 // Return false if dependencies must be regenerated and true
85 // otherwise.
86 virtual bool CheckDependencies(std::istream& internalDepends);
88 // Finalize the dependency information for the target.
89 virtual bool Finalize(std::ostream& makeDepends,
90 std::ostream& internalDepends);
92 // The directory in which the build rule for the target file is executed.
93 std::string CompileDirectory;
95 // The local generator.
96 cmLocalGenerator* LocalGenerator;
98 // Flag for verbose output.
99 bool Verbose;
100 cmFileTimeComparison* FileComparison;
102 std::string Language;
104 // The full path to the target's build directory.
105 std::string TargetDirectory;
107 size_t MaxPath;
108 char* Dependee;
109 char* Depender;
111 // The include file search path.
112 std::vector<std::string> IncludePath;
114 void SetIncludePathFromLanguage(const char* lang);
116 private:
117 cmDepends(cmDepends const&); // Purposely not implemented.
118 void operator=(cmDepends const&); // Purposely not implemented.
121 #endif