1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
15 #include "cmStandardIncludes.h"
17 class cmFileTimeComparison;
18 class cmLocalGenerator;
21 * \brief Dependency scanner superclass.
23 * This class is responsible for maintaining a .depends.make file in
24 * the build tree corresponding to an object file. Subclasses help it
25 * maintain dependencies for particular languages.
30 /** Instances need to know the build directory name and the relative
31 path from the build directory to the target file. */
32 cmDepends(cmLocalGenerator* lg=0, const char* targetDir="");
34 /** at what level will the compile be done from */
35 void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;};
37 /** Set the local generator for the directory in which we are
38 scanning dependencies. This is not a full local generator; it
39 has been setup to do relative path conversions for the current
41 void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
43 /** Set the specific language to be scanned. */
44 void SetLanguage(const char* lang) { this->Language = lang; }
46 /** Set the target build directory. */
47 void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
49 /** should this be verbose in its output */
50 void SetVerbose(bool verb) { this->Verbose = verb; }
52 /** Virtual destructor to cleanup subclasses properly. */
55 /** Write dependencies for the target file. */
56 bool Write(std::ostream &makeDepends, std::ostream &internalDepends);
58 class DependencyVector: public std::vector<std::string> {};
60 /** Check dependencies for the target file. Returns true if
61 dependencies are okay and false if they must be generated. If
62 they must be generated Clear has already been called to wipe out
64 Dependencies which are still valid will be stored in validDeps. */
65 bool Check(const char *makeFile, const char* internalFile,
66 std::map<std::string, DependencyVector>& validDeps);
68 /** Clear dependencies for the target file so they will be regenerated. */
69 void Clear(const char *file);
71 /** Set the file comparison object */
72 void SetFileComparison(cmFileTimeComparison* fc) {
73 this->FileComparison = fc; }
77 // Write dependencies for the target file to the given stream.
78 // Return true for success and false for failure.
79 virtual bool WriteDependencies(const char *src, const char* obj,
80 std::ostream& makeDepends, std::ostream& internalDepends);
82 // Check dependencies for the target file in the given stream.
83 // Return false if dependencies must be regenerated and true
85 virtual bool CheckDependencies(std::istream& internalDepends,
86 std::map<std::string, DependencyVector>& validDeps);
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.
100 cmFileTimeComparison* FileComparison;
102 std::string Language;
104 // The full path to the target's build directory.
105 std::string TargetDirectory;
111 // The include file search path.
112 std::vector<std::string> IncludePath;
114 void SetIncludePathFromLanguage(const char* lang);
117 cmDepends(cmDepends const&); // Purposely not implemented.
118 void operator=(cmDepends const&); // Purposely not implemented.