| 405 | } |
| 406 | |
| 407 | bool 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 | |
| 452 | bool HandleNormalPathCommand(std::vector<std::string> const& args, |
| 453 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…