| 178 | std::string& errorMsg); |
| 179 | |
| 180 | bool cmSourceGroupCommand(std::vector<std::string> const& args, |
| 181 | cmExecutionStatus& status) |
| 182 | { |
| 183 | if (args.empty()) { |
| 184 | status.SetError("called with incorrect number of arguments"); |
| 185 | return false; |
| 186 | } |
| 187 | |
| 188 | cmMakefile& mf = status.GetMakefile(); |
| 189 | |
| 190 | // If only two arguments are given, the pre-1.8 version of the |
| 191 | // command is being invoked. |
| 192 | bool isShortTreeSyntax = |
| 193 | ((args.size() == 2) && (args[0] == kTreeOptionName) && |
| 194 | cmSystemTools::FileIsDirectory(args[1])); |
| 195 | if (args.size() == 2 && args[1] != kFilesOptionName && !isShortTreeSyntax) { |
| 196 | cmSourceGroup* sg = mf.GetOrCreateSourceGroup(args[0]); |
| 197 | |
| 198 | if (!sg) { |
| 199 | status.SetError("Could not create or find source group"); |
| 200 | return false; |
| 201 | } |
| 202 | |
| 203 | sg->SetGroupRegex(args[1].c_str()); |
| 204 | return true; |
| 205 | } |
| 206 | |
| 207 | ParsedArguments parsedArguments; |
| 208 | std::string errorMsg; |
| 209 | |
| 210 | parseArguments(args, parsedArguments); |
| 211 | |
| 212 | if (!checkArgumentsPreconditions(parsedArguments, errorMsg)) { |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | if (parsedArguments.find(kTreeOptionName) != parsedArguments.end()) { |
| 217 | if (!processTree(mf, parsedArguments, errorMsg)) { |
| 218 | status.SetError(errorMsg); |
| 219 | return false; |
| 220 | } |
| 221 | } else { |
| 222 | if (parsedArguments.find(kSourceGroupOptionName) == |
| 223 | parsedArguments.end()) { |
| 224 | status.SetError("Missing source group name."); |
| 225 | return false; |
| 226 | } |
| 227 | |
| 228 | cmSourceGroup* sg = mf.GetOrCreateSourceGroup(args[0]); |
| 229 | |
| 230 | if (!sg) { |
| 231 | status.SetError("Could not create or find source group"); |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | // handle regex |
| 236 | if (parsedArguments.find(kRegexOptionName) != parsedArguments.end()) { |
| 237 | std::string const& sgRegex = parsedArguments[kRegexOptionName].front(); |
nothing calls this directly
no test coverage detected
searching dependent graphs…