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

Function HandleRemoveExtensionCommand

Source/cmCMakePathCommand.cxx:364–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364bool HandleRemoveExtensionCommand(std::vector<std::string> const& args,
365 cmExecutionStatus& status)
366{
367 struct Arguments : public ArgumentParser::ParseResult
368 {
369 cm::optional<ArgumentParser::NonEmpty<std::string>> Output;
370 bool LastOnly = false;
371 };
372
373 static auto const parser =
374 ArgumentParserWithOutputVariable<Arguments>{}.Bind("LAST_ONLY"_s,
375 &Arguments::LastOnly);
376
377 Arguments const arguments = parser.Parse(args);
378
379 if (arguments.MaybeReportError(status.GetMakefile())) {
380 return true;
381 }
382
383 if (!parser.GetInputs().empty()) {
384 status.SetError("REMOVE_EXTENSION called with unexpected arguments.");
385 return false;
386 }
387
388 std::string inputPath;
389 if (!getInputPath(args[1], status, inputPath)) {
390 return false;
391 }
392
393 cmCMakePath path(inputPath);
394
395 if (arguments.LastOnly) {
396 path.RemoveExtension();
397 } else {
398 path.RemoveWideExtension();
399 }
400
401 status.GetMakefile().AddDefinition(
402 arguments.Output ? *arguments.Output : args[1], path.String());
403
404 return true;
405}
406
407bool HandleReplaceExtensionCommand(std::vector<std::string> const& args,
408 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 9

getInputPathFunction · 0.85
MaybeReportErrorMethod · 0.80
BindMethod · 0.45
ParseMethod · 0.45
GetMakefileMethod · 0.45
emptyMethod · 0.45
SetErrorMethod · 0.45
AddDefinitionMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…