| 362 | } |
| 363 | |
| 364 | bool 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 | |
| 407 | bool HandleReplaceExtensionCommand(std::vector<std::string> const& args, |
| 408 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…