cmSourceFile.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmSourceFile_h
  14. #define cmSourceFile_h
  15. #include "cmCustomCommand.h"
  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 instance as a concrete class with both a
  27. * .h and .cxx file.
  28. */
  29. cmSourceFile()
  30. {
  31. this->CustomCommand = 0;
  32. }
  33. ~cmSourceFile()
  34. {
  35. this->SetCustomCommand(0);
  36. }
  37. /**
  38. * Set the name of the file, given the directory the file should be
  39. * in. The various extensions provided are tried on the name
  40. * (e.g., cxx, cpp) in the directory to find the actual file.
  41. */
  42. bool SetName(const char* name, const char* dir,
  43. const std::vector<std::string>& sourceExts,
  44. const std::vector<std::string>& headerExts,
  45. const char* target = 0);
  46. /**
  47. * Get the list of the custom commands for this source file
  48. */
  49. const cmCustomCommand *GetCustomCommand() const
  50. {return this->CustomCommand;}
  51. cmCustomCommand *GetCustomCommand() {return this->CustomCommand;}
  52. void SetCustomCommand(cmCustomCommand *cc);
  53. /**
  54. * Set the name of the file, given the directory the file should be in. IN
  55. * this version the extension is provided in the call. This is useful for
  56. * generated files that do not exist prior to the build.
  57. */
  58. void SetName(const char* name, const char* dir, const char *ext,
  59. bool headerFileOnly);
  60. /**
  61. * Print the structure to std::cout.
  62. */
  63. void Print() const;
  64. ///! Set/Get a property of this source file
  65. void SetProperty(const char *prop, const char *value);
  66. const char *GetProperty(const char *prop) const;
  67. bool GetPropertyAsBool(const char *prop) const;
  68. /**
  69. * The full path to the file.
  70. */
  71. const std::string &GetFullPath() const {return this->FullPath;}
  72. void SetFullPath(const char *name) {this->FullPath = name;}
  73. /**
  74. * The file name associated with stripped off directory and extension.
  75. * (In most cases this is the name of the class.)
  76. */
  77. const std::string &GetSourceName() const {return this->SourceName;}
  78. void SetSourceName(const char *name) {this->SourceName = name;}
  79. /**
  80. * The file extension associated with source file
  81. */
  82. const std::string &GetSourceExtension() const {
  83. return this->SourceExtension;}
  84. void SetSourceExtension(const char *name) {this->SourceExtension = name;}
  85. /**
  86. * Return the vector that holds the list of dependencies
  87. */
  88. const std::vector<std::string> &GetDepends() const {return this->Depends;}
  89. std::vector<std::string> &GetDepends() {return this->Depends;}
  90. /**
  91. * Get the source name without last extension
  92. */
  93. const std::string& GetSourceNameWithoutLastExtension();
  94. private:
  95. std::map<cmStdString,cmStdString> Properties;
  96. cmCustomCommand *CustomCommand;
  97. std::string FullPath;
  98. std::string SourceName;
  99. std::string SourceExtension;
  100. std::vector<std::string> Depends;
  101. std::string SourceNameWithoutLastExtension;
  102. };
  103. #endif