cmSourceFile.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. m_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. void SetName(const char* name, const char* dir,
  43. const std::vector<std::string>& sourceExts,
  44. const std::vector<std::string>& headerExts);
  45. /**
  46. * Get the list of the custom commands for this source file
  47. */
  48. const cmCustomCommand *GetCustomCommand() const
  49. {return m_CustomCommand;}
  50. cmCustomCommand *GetCustomCommand() {return m_CustomCommand;}
  51. void SetCustomCommand(cmCustomCommand *cc);
  52. /**
  53. * Set the name of the file, given the directory the file should be in. IN
  54. * this version the extension is provided in the call. This is useful for
  55. * generated files that do not exist prior to the build.
  56. */
  57. void SetName(const char* name, const char* dir, const char *ext,
  58. bool headerFileOnly);
  59. /**
  60. * Print the structure to std::cout.
  61. */
  62. void Print() const;
  63. ///! Set/Get a property of this source file
  64. void SetProperty(const char *prop, const char *value);
  65. const char *GetProperty(const char *prop) const;
  66. bool GetPropertyAsBool(const char *prop) const;
  67. /**
  68. * The full path to the file.
  69. */
  70. const std::string &GetFullPath() const {return m_FullPath;}
  71. void SetFullPath(const char *name) {m_FullPath = name;}
  72. /**
  73. * The file name associated with stripped off directory and extension.
  74. * (In most cases this is the name of the class.)
  75. */
  76. const std::string &GetSourceName() const {return m_SourceName;}
  77. void SetSourceName(const char *name) {m_SourceName = name;}
  78. /**
  79. * The file extension associated with source file
  80. */
  81. const std::string &GetSourceExtension() const {return m_SourceExtension;}
  82. void SetSourceExtension(const char *name) {m_SourceExtension = name;}
  83. /**
  84. * Return the vector that holds the list of dependencies
  85. */
  86. const std::vector<std::string> &GetDepends() const {return m_Depends;}
  87. std::vector<std::string> &GetDepends() {return m_Depends;}
  88. private:
  89. std::map<cmStdString,cmStdString> m_Properties;
  90. cmCustomCommand *m_CustomCommand;
  91. std::string m_FullPath;
  92. std::string m_SourceName;
  93. std::string m_SourceExtension;
  94. std::vector<std::string> m_Depends;
  95. };
  96. #endif