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

Function HandleConvertCommand

Source/cmCMakePathCommand.cxx:592–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592bool 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 }

Callers

nothing calls this directly

Calls 14

cmCMakePathClass · 0.85
assignMethod · 0.80
NormalMethod · 0.80
GenericStringMethod · 0.80
NativeStringMethod · 0.80
to_stringMethod · 0.80
joinMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…