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 ============================================================================*/
12 #ifndef cmSourceFileLocation_h
13 #define cmSourceFileLocation_h
15 #include "cmStandardIncludes.h"
19 /** \class cmSourceFileLocation
20 * \brief cmSourceFileLocation tracks knowledge about a source file location
22 * Source files can be referenced by a variety of names. The
23 * directory and/or extension may be omitted leading to a certain
24 * level of ambiguity about the source file location. This class is
25 * used by cmSourceFile to keep track of what is known about the
26 * source file location. Each reference may add some information
27 * about the directory or extension of the file.
29 class cmSourceFileLocation
33 * Construct for a source file created in a given cmMakefile
34 * instance with an initial name.
36 cmSourceFileLocation(cmMakefile* mf, const char* name);
39 * Return whether the givne source file location could refers to the
40 * same source file as this location given the level of ambiguity in
43 bool Matches(cmSourceFileLocation const& loc);
46 * Explicity state that the source file is located in the source tree.
48 void DirectoryUseSource();
51 * Explicity state that the source file is located in the build tree.
53 void DirectoryUseBinary();
56 * Return whether the directory containing the source is ambiguous.
58 bool DirectoryIsAmbiguous() const { return this->AmbiguousDirectory; }
61 * Return whether the extension of the source name is ambiguous.
63 bool ExtensionIsAmbiguous() const { return this->AmbiguousExtension; }
66 * Get the directory containing the file as best is currently known.
67 * If DirectoryIsAmbiguous() returns false this will be a full path.
68 * Otherwise it will be a relative path (possibly empty) that is
69 * either with respect to the source or build tree.
71 const char* GetDirectory() const { return this->Directory.c_str(); }
74 * Get the file name as best is currently known. If
75 * ExtensionIsAmbiguous() returns true this name may not be the
76 * final name (but could be). Otherwise the returned name is the
79 const char* GetName() const { return this->Name.c_str(); }
82 * Get the cmMakefile instance for which the source file was created.
84 cmMakefile* GetMakefile() const { return this->Makefile; }
87 bool AmbiguousDirectory;
88 bool AmbiguousExtension;
89 std::string Directory;
92 bool MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const;
94 // Update the location with additional knowledge.
95 void Update(cmSourceFileLocation const& loc);
96 void Update(const char* name);
97 void UpdateExtension(const char* name);
98 void UpdateDirectory(const char* name);