BUG: Fix find_* search order with path suffixes
[cmake.git] / Source / cmSourceFile.h
blob93f207a757804ba8d9ec9a5f00276414b61ea722
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSourceFile.h,v $
5 Language: C++
6 Date: $Date: 2008-04-29 18:17:42 $
7 Version: $Revision: 1.26 $
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 cmSourceFile_h
18 #define cmSourceFile_h
20 #include "cmSourceFileLocation.h"
21 #include "cmCustomCommand.h"
22 #include "cmPropertyMap.h"
24 class cmake;
26 /** \class cmSourceFile
27 * \brief Represent a class loaded from a makefile.
29 * cmSourceFile is represents a class loaded from
30 * a makefile.
32 class cmSourceFile
34 public:
35 /**
36 * Construct with the makefile storing the source and the initial
37 * name referencing it.
39 cmSourceFile(cmMakefile* mf, const char* name);
41 ~cmSourceFile();
43 /**
44 * Get the list of the custom commands for this source file
46 cmCustomCommand* GetCustomCommand();
47 cmCustomCommand const* GetCustomCommand() const;
48 void SetCustomCommand(cmCustomCommand *cc);
50 ///! Set/Get a property of this source file
51 void SetProperty(const char *prop, const char *value);
52 void AppendProperty(const char* prop, const char* value);
53 const char *GetProperty(const char *prop) const;
54 bool GetPropertyAsBool(const char *prop) const;
56 /** Implement getting a property when called from a CMake language
57 command like get_property or get_source_file_property. */
58 const char* GetPropertyForUser(const char *prop);
60 /**
61 * The full path to the file. The non-const version of this method
62 * may attempt to locate the file on disk and finalize its location.
63 * The const version of this method may return an empty string if
64 * the non-const version has not yet been called (yes this is a
65 * horrible interface, but is necessary for backwards
66 * compatibility).
68 std::string const& GetFullPath();
69 std::string const& GetFullPath() const;
71 /**
72 * Get the information currently known about the source file
73 * location without attempting to locate the file as GetFullPath
74 * would. See cmSourceFileLocation documentation.
76 cmSourceFileLocation const& GetLocation() const;
78 /**
79 * Get the file extension of this source file.
81 std::string const& GetExtension() const;
83 /**
84 * Get the language of the compiler to use for this source file.
86 const char* GetLanguage();
87 const char* GetLanguage() const;
89 /**
90 * Return the vector that holds the list of dependencies
92 const std::vector<std::string> &GetDepends() const {return this->Depends;}
93 void AddDepend(const char* d) { this->Depends.push_back(d); }
95 // Get the properties
96 cmPropertyMap &GetProperties() { return this->Properties; };
98 // Define the properties
99 static void DefineProperties(cmake *cm);
102 * Check whether the given source file location could refer to this
103 * source.
105 bool Matches(cmSourceFileLocation const&);
107 private:
108 cmSourceFileLocation Location;
109 cmPropertyMap Properties;
110 cmCustomCommand* CustomCommand;
111 std::string Extension;
112 std::string Language;
113 std::string FullPath;
114 bool FindFullPathFailed;
116 bool FindFullPath();
117 bool TryFullPath(const char* tryPath, const char* ext);
118 void CheckExtension();
119 void CheckLanguage(std::string const& ext);
121 std::vector<std::string> Depends;
124 #endif