Introduce "generator expressions" to add_test()
[cmake.git] / Source / cmSourceFileLocation.h
blob407ced2d32900f47f86e69341a233afa45505be2
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSourceFileLocation.h,v $
5 Language: C++
6 Date: $Date: 2008-08-05 17:27:01 $
7 Version: $Revision: 1.3 $
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"
22 class cmMakefile;
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
36 public:
37 /**
38 * Construct for a source file created in a given cmMakefile
39 * instance with an initial name.
41 cmSourceFileLocation(cmMakefile* mf, const char* name);
43 /**
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
46 * each location.
48 bool Matches(cmSourceFileLocation const& loc);
50 /**
51 * Explicity state that the source file is located in the source tree.
53 void DirectoryUseSource();
55 /**
56 * Explicity state that the source file is located in the build tree.
58 void DirectoryUseBinary();
60 /**
61 * Return whether the directory containing the source is ambiguous.
63 bool DirectoryIsAmbiguous() const { return this->AmbiguousDirectory; }
65 /**
66 * Return whether the extension of the source name is ambiguous.
68 bool ExtensionIsAmbiguous() const { return this->AmbiguousExtension; }
70 /**
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(); }
78 /**
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
82 * final name.
84 const char* GetName() const { return this->Name.c_str(); }
86 /**
87 * Get the cmMakefile instance for which the source file was created.
89 cmMakefile* GetMakefile() const { return this->Makefile; }
90 private:
91 cmMakefile* Makefile;
92 bool AmbiguousDirectory;
93 bool AmbiguousExtension;
94 std::string Directory;
95 std::string Name;
97 bool MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const;
99 // Update the location with additional knowledge.
100 void Update(cmSourceFileLocation const& loc);
101 void Update(const char* name);
102 void UpdateExtension(const char* name);
103 void UpdateDirectory(const char* name);
106 #endif