cmSourceFile.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "cmStandardIncludes.h"
  16. #include "cmCustomCommand.h"
  17. /** \class cmSourceFile
  18. * \brief Represent a class loaded from a makefile.
  19. *
  20. * cmSourceFile is represents a class loaded from
  21. * a makefile.
  22. */
  23. class cmSourceFile
  24. {
  25. public:
  26. /**
  27. * Construct instance as a concrete class with both a
  28. * .h and .cxx file.
  29. */
  30. cmSourceFile()
  31. {
  32. m_CustomCommand = 0;
  33. }
  34. ~cmSourceFile()
  35. {
  36. if (m_CustomCommand) { delete m_CustomCommand; }
  37. }
  38. /**
  39. * Set the name of the file, given the directory the file should be
  40. * in. The various extensions provided are tried on the name
  41. * (e.g., cxx, cpp) in the directory to find the actual file.
  42. */
  43. void SetName(const char* name, const char* dir,
  44. const std::vector<std::string>& sourceExts,
  45. const std::vector<std::string>& headerExts);
  46. /**
  47. * Get the list of the custom commands for this source file
  48. */
  49. const cmCustomCommand *GetCustomCommand() const
  50. {return m_CustomCommand;}
  51. cmCustomCommand *GetCustomCommand() {return m_CustomCommand;}
  52. void SetCustomCommand(cmCustomCommand *cc)
  53. { m_CustomCommand = cc;}
  54. /**
  55. * Set the name of the file, given the directory the file should be in. IN
  56. * this version the extension is provided in the call. This is useful for
  57. * generated files that do not exist prior to the build.
  58. */
  59. void SetName(const char* name, const char* dir, const char *ext,
  60. bool headerFileOnly);
  61. /**
  62. * Print the structure to std::cout.
  63. */
  64. void Print() const;
  65. ///! Set/Get a property of this source file
  66. void SetProperty(const char *prop, const char *value);
  67. const char *GetProperty(const char *prop) const;
  68. bool GetPropertyAsBool(const char *prop) const;
  69. /**
  70. * The full path to the file.
  71. */
  72. const std::string &GetFullPath() const {return m_FullPath;}
  73. void SetFullPath(const char *name) {m_FullPath = name;}
  74. /**
  75. * The file name associated with stripped off directory and extension.
  76. * (In most cases this is the name of the class.)
  77. */
  78. const std::string &GetSourceName() const {return m_SourceName;}
  79. void SetSourceName(const char *name) {m_SourceName = name;}
  80. /**
  81. * The file extension associated with source file
  82. */
  83. const std::string &GetSourceExtension() const {return m_SourceExtension;}
  84. void SetSourceExtension(const char *name) {m_SourceExtension = name;}
  85. /**
  86. * Return the vector that holds the list of dependencies
  87. */
  88. const std::vector<std::string> &GetDepends() const {return m_Depends;}
  89. std::vector<std::string> &GetDepends() {return m_Depends;}
  90. private:
  91. std::map<cmStdString,cmStdString> m_Properties;
  92. cmCustomCommand *m_CustomCommand;
  93. std::string m_FullPath;
  94. std::string m_SourceName;
  95. std::string m_SourceExtension;
  96. std::vector<std::string> m_Depends;
  97. };
  98. #endif