cmSourceGroup.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 cmSourceGroup_h
  14. #define cmSourceGroup_h
  15. #include "cmStandardIncludes.h"
  16. #include "cmRegularExpression.h"
  17. #include "cmCustomCommand.h"
  18. class cmSourceFile;
  19. /** \class cmSourceGroup
  20. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  21. *
  22. * cmSourceGroup holds all the source files and corresponding commands
  23. * for files matching the regular expression specified for the group.
  24. */
  25. class cmSourceGroup
  26. {
  27. public:
  28. cmSourceGroup(const char* name, const char* regex);
  29. cmSourceGroup(const cmSourceGroup&);
  30. ~cmSourceGroup() {}
  31. struct CommandFiles
  32. {
  33. CommandFiles() {}
  34. CommandFiles(const CommandFiles& r):
  35. m_Comment(r.m_Comment), m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
  36. void Merge(const CommandFiles &r);
  37. std::string m_Command;
  38. std::string m_Arguments;
  39. std::string m_Comment;
  40. std::set<std::string> m_Outputs;
  41. std::set<std::string> m_Depends;
  42. };
  43. /**
  44. * Map from command to its output/depends sets.
  45. */
  46. typedef std::map<cmStdString, CommandFiles> Commands;
  47. struct SourceAndCommands
  48. {
  49. SourceAndCommands(): m_SourceFile(0) {}
  50. const cmSourceFile* m_SourceFile;
  51. Commands m_Commands;
  52. };
  53. /**
  54. * Map from source to command map.
  55. */
  56. typedef std::map<cmStdString, SourceAndCommands> BuildRules;
  57. bool Matches(const char* name);
  58. void SetGroupRegex(const char* regex)
  59. { m_GroupRegex.compile(regex); }
  60. void AddSource(const char* name, const cmSourceFile*);
  61. void AddCustomCommand(const cmCustomCommand &cmd);
  62. const char* GetName() const
  63. { return m_Name.c_str(); }
  64. const BuildRules& GetBuildRules() const
  65. { return m_BuildRules; }
  66. void Print() const;
  67. private:
  68. /**
  69. * The name of the source group.
  70. */
  71. std::string m_Name;
  72. /**
  73. * The regular expression matching the files in the group.
  74. */
  75. cmRegularExpression m_GroupRegex;
  76. /**
  77. * Map from source name to the commands to build from the source.
  78. * Some commands may build from files that the compiler also knows how to
  79. * build.
  80. */
  81. BuildRules m_BuildRules;
  82. };
  83. #endif