| 3556 | } |
| 3557 | |
| 3558 | bool HandleConfigureCommand(std::vector<std::string> const& args, |
| 3559 | cmExecutionStatus& status) |
| 3560 | { |
| 3561 | struct Arguments : public ArgumentParser::ParseResult |
| 3562 | { |
| 3563 | cm::optional<std::string> Output; |
| 3564 | cm::optional<std::string> Content; |
| 3565 | bool EscapeQuotes = false; |
| 3566 | bool AtOnly = false; |
| 3567 | // "NEWLINE_STYLE" requires one value, but we use a custom check below. |
| 3568 | ArgumentParser::Maybe<std::string> NewlineStyle; |
| 3569 | }; |
| 3570 | |
| 3571 | static auto const parser = |
| 3572 | cmArgumentParser<Arguments>{} |
| 3573 | .Bind("OUTPUT"_s, &Arguments::Output) |
| 3574 | .Bind("CONTENT"_s, &Arguments::Content) |
| 3575 | .Bind("ESCAPE_QUOTES"_s, &Arguments::EscapeQuotes) |
| 3576 | .Bind("@ONLY"_s, &Arguments::AtOnly) |
| 3577 | .Bind("NEWLINE_STYLE"_s, &Arguments::NewlineStyle); |
| 3578 | |
| 3579 | std::vector<std::string> unrecognizedArguments; |
| 3580 | auto parsedArgs = |
| 3581 | parser.Parse(cmMakeRange(args).advance(1), &unrecognizedArguments); |
| 3582 | |
| 3583 | auto argIt = unrecognizedArguments.begin(); |
| 3584 | if (argIt != unrecognizedArguments.end()) { |
| 3585 | status.SetError( |
| 3586 | cmStrCat("CONFIGURE Unrecognized argument: \"", *argIt, '"')); |
| 3587 | cmSystemTools::SetFatalErrorOccurred(); |
| 3588 | return false; |
| 3589 | } |
| 3590 | |
| 3591 | if (parsedArgs.MaybeReportError(status.GetMakefile())) { |
| 3592 | cmSystemTools::SetFatalErrorOccurred(); |
| 3593 | return true; |
| 3594 | } |
| 3595 | |
| 3596 | if (!parsedArgs.Output) { |
| 3597 | status.SetError("CONFIGURE OUTPUT option is mandatory."); |
| 3598 | cmSystemTools::SetFatalErrorOccurred(); |
| 3599 | return false; |
| 3600 | } |
| 3601 | if (!parsedArgs.Content) { |
| 3602 | status.SetError("CONFIGURE CONTENT option is mandatory."); |
| 3603 | cmSystemTools::SetFatalErrorOccurred(); |
| 3604 | return false; |
| 3605 | } |
| 3606 | |
| 3607 | std::string errorMessage; |
| 3608 | cmNewLineStyle newLineStyle; |
| 3609 | if (!newLineStyle.ReadFromArguments(args, errorMessage)) { |
| 3610 | status.SetError(cmStrCat("CONFIGURE ", errorMessage)); |
| 3611 | return false; |
| 3612 | } |
| 3613 | |
| 3614 | // Check for generator expressions |
| 3615 | std::string outputFile = cmSystemTools::CollapseFullPath( |
nothing calls this directly
no test coverage detected
searching dependent graphs…