1
0

cmSourceGroup.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 <cmsys/RegularExpression.hxx>
  17. class cmSourceFile;
  18. /** \class cmSourceGroup
  19. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  20. *
  21. * cmSourceGroup holds a regular expression and a list of files. When
  22. * local generators are about to generate the rules for a target's
  23. * files, the set of source groups is consulted to group files
  24. * together. A file is placed into the last source group that lists
  25. * the file by name. If no group lists the file, it is placed into
  26. * the last group whose regex matches it.
  27. */
  28. class cmSourceGroup
  29. {
  30. public:
  31. cmSourceGroup(const char* name, const char* regex);
  32. ~cmSourceGroup() {}
  33. /**
  34. * Set the regular expression for this group.
  35. */
  36. void SetGroupRegex(const char* regex);
  37. /**
  38. * Add a file name to the explicit list of files for this group.
  39. */
  40. void AddGroupFile(const char* name);
  41. /**
  42. * Get the name of this group.
  43. */
  44. const char* GetName() const;
  45. /**
  46. * Check if the given name matches this group's regex.
  47. */
  48. bool MatchesRegex(const char* name);
  49. /**
  50. * Check if the given name matches this group's explicit file list.
  51. */
  52. bool MatchesFiles(const char* name);
  53. /**
  54. * Assign the given source file to this group. Used only by
  55. * generators.
  56. */
  57. void AssignSource(const cmSourceFile* sf);
  58. /**
  59. * Get the list of the source files that have been assigned to this
  60. * source group.
  61. */
  62. const std::vector<const cmSourceFile*>& GetSourceFiles() const;
  63. std::vector<const cmSourceFile*>& GetSourceFiles();
  64. private:
  65. /**
  66. * The name of the source group.
  67. */
  68. std::string m_Name;
  69. /**
  70. * The regular expression matching the files in the group.
  71. */
  72. cmsys::RegularExpression m_GroupRegex;
  73. /**
  74. * Set of file names explicitly added to this group.
  75. */
  76. std::set<cmStdString> m_GroupFiles;
  77. /**
  78. * Vector of all source files that have been assigned to
  79. * this group.
  80. */
  81. std::vector<const cmSourceFile*> m_SourceFiles;
  82. };
  83. #endif