packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmSourceFile.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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
14
15 #include "cmSourceFileLocation.h"
16 #include "cmCustomCommand.h"
17 #include "cmPropertyMap.h"
18
19 class cmake;
20
21 /** \class cmSourceFile
22  * \brief Represent a class loaded from a makefile.
23  *
24  * cmSourceFile is represents a class loaded from
25  * a makefile.
26  */
27 class cmSourceFile
28 {
29 public:
30   /**
31    * Construct with the makefile storing the source and the initial
32    * name referencing it.
33    */
34   cmSourceFile(cmMakefile* mf, const char* name);
35
36   ~cmSourceFile();
37
38   /**
39    * Get the list of the custom commands for this source file
40    */
41   cmCustomCommand* GetCustomCommand();
42   cmCustomCommand const* GetCustomCommand() const;
43   void SetCustomCommand(cmCustomCommand *cc);
44
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;
50
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);
54
55   /**
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
61    * compatibility).
62    */
63   std::string const& GetFullPath(std::string* error = 0);
64   std::string const& GetFullPath() const;
65
66   /**
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.
70    */
71   cmSourceFileLocation const& GetLocation() const;
72
73   /**
74    * Get the file extension of this source file.
75    */
76   std::string const& GetExtension() const;
77
78   /**
79    * Get the language of the compiler to use for this source file.
80    */
81   const char* GetLanguage();
82   const char* GetLanguage() const;
83
84   /**
85    * Return the vector that holds the list of dependencies
86    */
87   const std::vector<std::string> &GetDepends() const {return this->Depends;}
88   void AddDepend(const char* d) { this->Depends.push_back(d); }
89
90   // Get the properties
91   cmPropertyMap &GetProperties() { return this->Properties; };
92
93   // Define the properties
94   static void DefineProperties(cmake *cm);
95
96   /**
97    * Check whether the given source file location could refer to this
98    * source.
99    */
100   bool Matches(cmSourceFileLocation const&);
101
102 private:
103   cmSourceFileLocation Location;
104   cmPropertyMap Properties;
105   cmCustomCommand* CustomCommand;
106   std::string Extension;
107   std::string Language;
108   std::string FullPath;
109   bool FindFullPathFailed;
110
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);
115
116   std::vector<std::string> Depends;
117 };
118
119 // TODO: Factor out into platform information modules.
120 #define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"
121
122 #endif