cmSourceFile.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmSourceFile_h
  11. #define cmSourceFile_h
  12. #include "cmSourceFileLocation.h"
  13. #include "cmCustomCommand.h"
  14. #include "cmPropertyMap.h"
  15. class cmake;
  16. /** \class cmSourceFile
  17. * \brief Represent a class loaded from a makefile.
  18. *
  19. * cmSourceFile is represents a class loaded from
  20. * a makefile.
  21. */
  22. class cmSourceFile
  23. {
  24. public:
  25. /**
  26. * Construct with the makefile storing the source and the initial
  27. * name referencing it.
  28. */
  29. cmSourceFile(cmMakefile* mf, const std::string& name);
  30. ~cmSourceFile();
  31. /**
  32. * Get the list of the custom commands for this source file
  33. */
  34. cmCustomCommand* GetCustomCommand();
  35. cmCustomCommand const* GetCustomCommand() const;
  36. void SetCustomCommand(cmCustomCommand *cc);
  37. ///! Set/Get a property of this source file
  38. void SetProperty(const std::string& prop, const char *value);
  39. void AppendProperty(const std::string& prop,
  40. const char* value,bool asString=false);
  41. const char *GetProperty(const std::string& prop) const;
  42. bool GetPropertyAsBool(const std::string& prop) const;
  43. /** Implement getting a property when called from a CMake language
  44. command like get_property or get_source_file_property. */
  45. const char* GetPropertyForUser(const std::string& prop);
  46. /**
  47. * The full path to the file. The non-const version of this method
  48. * may attempt to locate the file on disk and finalize its location.
  49. * The const version of this method may return an empty string if
  50. * the non-const version has not yet been called (yes this is a
  51. * horrible interface, but is necessary for backwards
  52. * compatibility).
  53. */
  54. std::string const& GetFullPath(std::string* error = 0);
  55. std::string const& GetFullPath() const;
  56. /**
  57. * Get the information currently known about the source file
  58. * location without attempting to locate the file as GetFullPath
  59. * would. See cmSourceFileLocation documentation.
  60. */
  61. cmSourceFileLocation const& GetLocation() const;
  62. /**
  63. * Get the file extension of this source file.
  64. */
  65. std::string const& GetExtension() const;
  66. /**
  67. * Get the language of the compiler to use for this source file.
  68. */
  69. std::string GetLanguage();
  70. std::string GetLanguage() const;
  71. /**
  72. * Return the vector that holds the list of dependencies
  73. */
  74. const std::vector<std::string> &GetDepends() const {return this->Depends;}
  75. void AddDepend(const char* d) { this->Depends.push_back(d); }
  76. // Get the properties
  77. cmPropertyMap &GetProperties() { return this->Properties; };
  78. /**
  79. * Check whether the given source file location could refer to this
  80. * source.
  81. */
  82. bool Matches(cmSourceFileLocation const&);
  83. void SetObjectLibrary(std::string const& objlib);
  84. std::string GetObjectLibrary() const;
  85. private:
  86. cmSourceFileLocation Location;
  87. cmPropertyMap Properties;
  88. cmCustomCommand* CustomCommand;
  89. std::string Extension;
  90. std::string Language;
  91. std::string FullPath;
  92. bool FindFullPathFailed;
  93. std::string ObjectLibrary;
  94. bool FindFullPath(std::string* error);
  95. bool TryFullPath(const std::string& path, const std::string& ext);
  96. void CheckExtension();
  97. void CheckLanguage(std::string const& ext);
  98. std::vector<std::string> Depends;
  99. };
  100. // TODO: Factor out into platform information modules.
  101. #define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"
  102. #endif