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 cmSourceFile_h
13 #define cmSourceFile_h
15 #include "cmSourceFileLocation.h"
16 #include "cmCustomCommand.h"
17 #include "cmPropertyMap.h"
21 /** \class cmSourceFile
22 * \brief Represent a class loaded from a makefile.
24 * cmSourceFile is represents a class loaded from
31 * Construct with the makefile storing the source and the initial
32 * name referencing it.
34 cmSourceFile(cmMakefile* mf, const char* name);
39 * Get the list of the custom commands for this source file
41 cmCustomCommand* GetCustomCommand();
42 cmCustomCommand const* GetCustomCommand() const;
43 void SetCustomCommand(cmCustomCommand *cc);
45 ///! Set/Get a property of this source file
46 void SetProperty(const char *prop, const char *value);
47 void AppendProperty(const char* prop, const char* value,bool asString=false);
48 const char *GetProperty(const char *prop) const;
49 bool GetPropertyAsBool(const char *prop) const;
51 /** Implement getting a property when called from a CMake language
52 command like get_property or get_source_file_property. */
53 const char* GetPropertyForUser(const char *prop);
56 * The full path to the file. The non-const version of this method
57 * may attempt to locate the file on disk and finalize its location.
58 * The const version of this method may return an empty string if
59 * the non-const version has not yet been called (yes this is a
60 * horrible interface, but is necessary for backwards
63 std::string const& GetFullPath(std::string* error = 0);
64 std::string const& GetFullPath() const;
67 * Get the information currently known about the source file
68 * location without attempting to locate the file as GetFullPath
69 * would. See cmSourceFileLocation documentation.
71 cmSourceFileLocation const& GetLocation() const;
74 * Get the file extension of this source file.
76 std::string const& GetExtension() const;
79 * Get the language of the compiler to use for this source file.
81 const char* GetLanguage();
82 const char* GetLanguage() const;
85 * Return the vector that holds the list of dependencies
87 const std::vector<std::string> &GetDepends() const {return this->Depends;}
88 void AddDepend(const char* d) { this->Depends.push_back(d); }
91 cmPropertyMap &GetProperties() { return this->Properties; };
93 // Define the properties
94 static void DefineProperties(cmake *cm);
97 * Check whether the given source file location could refer to this
100 bool Matches(cmSourceFileLocation const&);
103 cmSourceFileLocation Location;
104 cmPropertyMap Properties;
105 cmCustomCommand* CustomCommand;
106 std::string Extension;
107 std::string Language;
108 std::string FullPath;
109 bool FindFullPathFailed;
111 bool FindFullPath(std::string* error);
112 bool TryFullPath(const char* tryPath, const char* ext);
113 void CheckExtension();
114 void CheckLanguage(std::string const& ext);
116 std::vector<std::string> Depends;
119 // TODO: Factor out into platform information modules.
120 #define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"