1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
12 #include "cmsys/RegularExpression.hxx"
15 class cmSourceGroupInternals;
17 /** \class cmSourceGroup
18 * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
20 * cmSourceGroup holds a regular expression and a list of files. When
21 * local generators are about to generate the rules for a target's
22 * files, the set of source groups is consulted to group files
23 * together. A file is placed into the last source group that lists
24 * the file by name. If no group lists the file, it is placed into
25 * the last group whose regex matches it.
30 cmSourceGroup(std::string name, const char* regex,
31 const char* parentName = nullptr);
32 cmSourceGroup(cmSourceGroup const& r);
34 cmSourceGroup& operator=(cmSourceGroup const&);
37 * Set the regular expression for this group.
39 void SetGroupRegex(const char* regex);
42 * Add a file name to the explicit list of files for this group.
44 void AddGroupFile(const std::string& name);
47 * Add child to this sourcegroup
49 void AddChild(cmSourceGroup const& child);
52 * Looks up child and returns it
54 cmSourceGroup* LookupChild(const std::string& name);
57 * Get the name of this group.
59 std::string const& GetName() const;
62 * Get the full path name for group.
64 std::string const& GetFullName() const;
67 * Check if the given name matches this group's regex.
69 bool MatchesRegex(const std::string& name);
72 * Check if the given name matches this group's explicit file list.
74 bool MatchesFiles(const std::string& name) const;
77 * Check if the given name matches this group's explicit file list
80 cmSourceGroup* MatchChildrenFiles(const std::string& name);
83 * Check if the given name matches this group's explicit file list
86 const cmSourceGroup* MatchChildrenFiles(const std::string& name) const;
89 * Check if the given name matches this group's regex in children.
91 cmSourceGroup* MatchChildrenRegex(const std::string& name);
94 * Assign the given source file to this group. Used only by
97 void AssignSource(const cmSourceFile* sf);
100 * Get the list of the source files that have been assigned to this
103 const std::vector<const cmSourceFile*>& GetSourceFiles() const;
105 std::vector<cmSourceGroup> const& GetGroupChildren() const;
109 * The name of the source group.
112 // Full path to group
113 std::string FullName;
116 * The regular expression matching the files in the group.
118 cmsys::RegularExpression GroupRegex;
121 * Set of file names explicitly added to this group.
123 std::set<std::string> GroupFiles;
126 * Vector of all source files that have been assigned to
129 std::vector<const cmSourceFile*> SourceFiles;
131 std::unique_ptr<cmSourceGroupInternals> Internal;