MCPcopy Create free account
hub / github.com/Kitware/CMake / cmSourceGroupCommand

Function cmSourceGroupCommand

Source/cmSourceGroupCommand.cxx:180–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178 std::string& errorMsg);
179
180bool 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();

Callers

nothing calls this directly

Calls 14

parseArgumentsFunction · 0.85
processTreeFunction · 0.85
SetGroupRegexMethod · 0.80
c_strMethod · 0.80
AddGroupFileMethod · 0.80
emptyMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…