| 590 | } |
| 591 | |
| 592 | bool HandleConvertCommand(std::vector<std::string> const& args, |
| 593 | cmExecutionStatus& status) |
| 594 | { |
| 595 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 596 | auto const pathSep = ";"_s; |
| 597 | #else |
| 598 | auto const pathSep = ":"_s; |
| 599 | #endif |
| 600 | auto const cmakePath = "TO_CMAKE_PATH_LIST"_s; |
| 601 | auto const nativePath = "TO_NATIVE_PATH_LIST"_s; |
| 602 | |
| 603 | if (args.size() < 4 || args.size() > 5) { |
| 604 | status.SetError("CONVERT must be called with three or four arguments."); |
| 605 | return false; |
| 606 | } |
| 607 | |
| 608 | auto const& action = args[2]; |
| 609 | |
| 610 | if (action != cmakePath && action != nativePath) { |
| 611 | status.SetError( |
| 612 | cmStrCat("CONVERT called with an unknown action: ", action, '.')); |
| 613 | return false; |
| 614 | } |
| 615 | |
| 616 | if (args[3].empty()) { |
| 617 | status.SetError("Invalid name for output variable."); |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | static NormalizeParser const parser; |
| 622 | |
| 623 | auto const arguments = parser.Parse<4>(args); |
| 624 | |
| 625 | if (!parser.GetInputs().empty()) { |
| 626 | status.SetError("CONVERT called with unexpected arguments."); |
| 627 | return false; |
| 628 | } |
| 629 | |
| 630 | cmList paths; |
| 631 | |
| 632 | if (action == cmakePath) { |
| 633 | paths = cmSystemTools::SplitString(args[1], pathSep.front()); |
| 634 | } else { |
| 635 | paths.assign(args[1]); |
| 636 | } |
| 637 | |
| 638 | for (auto& path : paths) { |
| 639 | auto p = cmCMakePath(path, |
| 640 | action == cmakePath ? cmCMakePath::native_format |
| 641 | : cmCMakePath::generic_format); |
| 642 | if (arguments.Normalize) { |
| 643 | p = p.Normal(); |
| 644 | } |
| 645 | if (action == cmakePath) { |
| 646 | path = p.GenericString(); |
| 647 | } else { |
| 648 | path = p.NativeString(); |
| 649 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…