Add to groupsUsed empty source groups that have non-empty children.
| 2131 | |
| 2132 | // Add to groupsUsed empty source groups that have non-empty children. |
| 2133 | void cmVisualStudio10TargetGenerator::AddMissingSourceGroups( |
| 2134 | std::set<cmSourceGroup const*>& groupsUsed, |
| 2135 | SourceGroupVector const& allGroups) |
| 2136 | { |
| 2137 | for (auto const& current : allGroups) { |
| 2138 | SourceGroupVector const& children = current->GetGroupChildren(); |
| 2139 | if (children.empty()) { |
| 2140 | continue; // the group is really empty |
| 2141 | } |
| 2142 | |
| 2143 | this->AddMissingSourceGroups(groupsUsed, children); |
| 2144 | |
| 2145 | if (groupsUsed.count(current.get()) > 0) { |
| 2146 | continue; // group has already been added to set |
| 2147 | } |
| 2148 | |
| 2149 | // check if it least one of the group's descendants is not empty |
| 2150 | // (at least one child must already have been added) |
| 2151 | auto child_it = children.begin(); |
| 2152 | while (child_it != children.end()) { |
| 2153 | if (groupsUsed.count(child_it->get()) > 0) { |
| 2154 | break; // found a child that was already added => add current group too |
| 2155 | } |
| 2156 | ++child_it; |
| 2157 | } |
| 2158 | |
| 2159 | if (child_it == children.end()) { |
| 2160 | continue; // no descendants have source files => ignore this group |
| 2161 | } |
| 2162 | |
| 2163 | groupsUsed.insert(current.get()); |
| 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | void cmVisualStudio10TargetGenerator::WriteGroupSources( |
| 2168 | Elem& e0, std::string const& name, ToolSources const& sources) |