cmSourceFile.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 char* 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 char *prop, const char *value);
  39. void AppendProperty(const char* prop, const char* value);
  40. const char *GetProperty(const char *prop) const;
  41. bool GetPropertyAsBool(const char *prop) const;
  42. /** Implement getting a property when called from a CMake language
  43. command like get_property or get_source_file_property. */
  44. const char* GetPropertyForUser(const char *prop);
  45. /**
  46. * The full path to the file. The non-const version of this method
  47. * may attempt to locate the file on disk and finalize its location.
  48. * The const version of this method may return an empty string if
  49. * the non-const version has not yet been called (yes this is a
  50. * horrible interface, but is necessary for backwards
  51. * compatibility).
  52. */
  53. std::string const& GetFullPath(std::string* error = 0);
  54. std::string const& GetFullPath() const;
  55. /**
  56. * Get the information currently known about the source file
  57. * location without attempting to locate the file as GetFullPath
  58. * would. See cmSourceFileLocation documentation.
  59. */
  60. cmSourceFileLocation const& GetLocation() const;
  61. /**
  62. * Get the file extension of this source file.
  63. */
  64. std::string const& GetExtension() const;
  65. /**
  66. * Get the language of the compiler to use for this source file.
  67. */
  68. const char* GetLanguage();
  69. const char* GetLanguage() const;
  70. /**
  71. * Return the vector that holds the list of dependencies
  72. */
  73. const std::vector<std::string> &GetDepends() const {return this->Depends;}
  74. void AddDepend(const char* d) { this->Depends.push_back(d); }
  75. // Get the properties
  76. cmPropertyMap &GetProperties() { return this->Properties; };
  77. // Define the properties
  78. static void DefineProperties(cmake *cm);
  79. /**
  80. * Check whether the given source file location could refer to this
  81. * source.
  82. */
  83. bool Matches(cmSourceFileLocation const&);
  84. private:
  85. cmSourceFileLocation Location;
  86. cmPropertyMap Properties;
  87. cmCustomCommand* CustomCommand;
  88. std::string Extension;
  89. std::string Language;
  90. std::string FullPath;
  91. bool FindFullPathFailed;
  92. bool FindFullPath(std::string* error);
  93. bool TryFullPath(const char* tryPath, const char* ext);
  94. void CheckExtension();
  95. void CheckLanguage(std::string const& ext);
  96. std::vector<std::string> Depends;
  97. };
  98. #endif