1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSourceFileLocation.h,v $
6 Date: $Date: 2007-06-18 15:59:23 $
7 Version: $Revision: 1.2 $
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 cmSourceFileLocation_h
18 #define cmSourceFileLocation_h
20 #include "cmStandardIncludes.h"
24 /** \class cmSourceFileLocation
25 * \brief cmSourceFileLocation tracks knowledge about a source file location
27 * Source files can be referenced by a variety of names. The
28 * directory and/or extension may be omitted leading to a certain
29 * level of ambiguity about the source file location. This class is
30 * used by cmSourceFile to keep track of what is known about the
31 * source file location. Each reference may add some information
32 * about the directory or extension of the file.
34 class cmSourceFileLocation
38 * Construct for a source file created in a given cmMakefile
39 * instance with an initial name.
41 cmSourceFileLocation(cmMakefile
* mf
, const char* name
);
44 * Return whether the givne source file location could refers to the
45 * same source file as this location given the level of ambiguity in
48 bool Matches(cmSourceFileLocation
const& loc
);
51 * Explicity state that the source file is located in the source tree.
53 void DirectoryUseSource();
56 * Explicity state that the source file is located in the build tree.
58 void DirectoryUseBinary();
61 * Return whether the directory containing the source is ambiguous.
63 bool DirectoryIsAmbiguous() const { return this->AmbiguousDirectory
; }
66 * Return whether the extension of the source name is ambiguous.
68 bool ExtensionIsAmbiguous() const { return this->AmbiguousExtension
; }
71 * Get the directory containing the file as best is currently known.
72 * If DirectoryIsAmbiguous() returns false this will be a full path.
73 * Otherwise it will be a relative path (possibly empty) that is
74 * either with respect to the source or build tree.
76 const char* GetDirectory() const { return this->Directory
.c_str(); }
79 * Get the file name as best is currently known. If
80 * ExtensionIsAmbiguous() returns true this name may not be the
81 * final name (but could be). Otherwise the returned name is the
84 const char* GetName() const { return this->Name
.c_str(); }
87 * Get the cmMakefile instance for which the source file was created.
89 cmMakefile
* GetMakefile() const { return this->Makefile
; }
92 bool AmbiguousDirectory
;
93 bool AmbiguousExtension
;
94 std::string Directory
;
97 // Update the location with additional knowledge.
98 void Update(cmSourceFileLocation
const& loc
);
99 void Update(const char* name
);
100 void UpdateExtension(const char* name
);
101 void UpdateDirectory(const char* name
);