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

Function HandleReplaceExtensionCommand

Source/cmCMakePathCommand.cxx:407–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407bool HandleReplaceExtensionCommand(std::vector<std::string> const& args,
408 cmExecutionStatus& status)
409{
410 struct Arguments : public ArgumentParser::ParseResult
411 {
412 cm::optional<ArgumentParser::NonEmpty<std::string>> Output;
413 bool LastOnly = false;
414 };
415
416 static auto const parser =
417 ArgumentParserWithOutputVariable<Arguments>{}.Bind("LAST_ONLY"_s,
418 &Arguments::LastOnly);
419
420 Arguments const arguments = parser.Parse(args);
421
422 if (arguments.MaybeReportError(status.GetMakefile())) {
423 return true;
424 }
425
426 if (parser.GetInputs().size() > 1) {
427 status.SetError("REPLACE_EXTENSION called with unexpected arguments.");
428 return false;
429 }
430
431 std::string inputPath;
432 if (!getInputPath(args[1], status, inputPath)) {
433 return false;
434 }
435
436 cmCMakePath path(inputPath);
437 cmCMakePath extension(
438 parser.GetInputs().empty() ? "" : parser.GetInputs().front());
439
440 if (arguments.LastOnly) {
441 path.ReplaceExtension(extension);
442 } else {
443 path.ReplaceWideExtension(extension);
444 }
445
446 status.GetMakefile().AddDefinition(
447 arguments.Output ? *arguments.Output : args[1], path.String());
448
449 return true;
450}
451
452bool HandleNormalPathCommand(std::vector<std::string> const& args,
453 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 11

getInputPathFunction · 0.85
MaybeReportErrorMethod · 0.80
BindMethod · 0.45
ParseMethod · 0.45
GetMakefileMethod · 0.45
sizeMethod · 0.45
SetErrorMethod · 0.45
emptyMethod · 0.45
frontMethod · 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…