1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #ifndef cmSourceGroup_h
13 #define cmSourceGroup_h
15 #include "cmStandardIncludes.h"
16 #include <cmsys/RegularExpression.hxx>
20 class cmSourceGroupInternals;
22 /** \class cmSourceGroup
23 * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
25 * cmSourceGroup holds a regular expression and a list of files. When
26 * local generators are about to generate the rules for a target's
27 * files, the set of source groups is consulted to group files
28 * together. A file is placed into the last source group that lists
29 * the file by name. If no group lists the file, it is placed into
30 * the last group whose regex matches it.
35 cmSourceGroup(const char* name, const char* regex,
36 const char* parentName=0);
37 cmSourceGroup(cmSourceGroup const& r);
39 cmSourceGroup& operator=(cmSourceGroup const&);
42 * Set the regular expression for this group.
44 void SetGroupRegex(const char* regex);
47 * Add a file name to the explicit list of files for this group.
49 void AddGroupFile(const char* name);
52 * Add child to this sourcegroup
54 void AddChild(cmSourceGroup child);
57 * Looks up child and returns it
59 cmSourceGroup *lookupChild(const char *name);
62 * Get the name of this group.
64 const char* GetName() const;
67 * Get the full path name for group.
69 const char* GetFullName() const;
72 * Check if the given name matches this group's regex.
74 bool MatchesRegex(const char* name);
77 * Check if the given name matches this group's explicit file list.
79 bool MatchesFiles(const char* name);
82 * Check if the given name matches this group's explicit file list
85 cmSourceGroup *MatchChildrenFiles(const char *name);
88 * Check if the given name matches this group's regex in children.
90 cmSourceGroup *MatchChildrenRegex(const char *name);
93 * Assign the given source file to this group. Used only by
96 void AssignSource(const cmSourceFile* sf);
99 * Get the list of the source files that have been assigned to this
102 const std::vector<const cmSourceFile*>& GetSourceFiles() const;
104 std::vector<cmSourceGroup> const& GetGroupChildren() const;
107 * The name of the source group.
110 // Full path to group
111 std::string FullName;
114 * The regular expression matching the files in the group.
116 cmsys::RegularExpression GroupRegex;
119 * Set of file names explicitly added to this group.
121 std::set<cmStdString> GroupFiles;
124 * Vector of all source files that have been assigned to
127 std::vector<const cmSourceFile*> SourceFiles;
129 cmSourceGroupInternals* Internal;