MCPcopy Index your code
hub / github.com/Kitware/CMake / HandleSortCommand

Function HandleSortCommand

Source/cmListCommand.cxx:695–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695bool HandleSortCommand(std::vector<std::string> const& args,
696 cmExecutionStatus& status)
697{
698 assert(args.size() >= 2);
699 if (args.size() > 8) {
700 status.SetError("sub-command SORT only takes up to six arguments.");
701 return false;
702 }
703
704 using SortConfig = cmList::SortConfiguration;
705 SortConfig sortConfig;
706
707 size_t argumentIndex = 2;
708 std::string const messageHint = "sub-command SORT ";
709
710 while (argumentIndex < args.size()) {
711 std::string const& option = args[argumentIndex++];
712 if (option == "COMPARE") {
713 if (sortConfig.Compare != SortConfig::CompareMethod::DEFAULT) {
714 std::string error = cmStrCat(messageHint, "option \"", option,
715 "\" has been specified multiple times.");
716 status.SetError(error);
717 return false;
718 }
719 if (argumentIndex < args.size()) {
720 std::string const& argument = args[argumentIndex++];
721 if (argument == "STRING") {
722 sortConfig.Compare = SortConfig::CompareMethod::STRING;
723 } else if (argument == "FILE_BASENAME") {
724 sortConfig.Compare = SortConfig::CompareMethod::FILE_BASENAME;
725 } else if (argument == "NATURAL") {
726 sortConfig.Compare = SortConfig::CompareMethod::NATURAL;
727 } else {
728 std::string error =
729 cmStrCat(messageHint, "value \"", argument, "\" for option \"",
730 option, "\" is invalid.");
731 status.SetError(error);
732 return false;
733 }
734 } else {
735 status.SetError(cmStrCat(messageHint, "missing argument for option \"",
736 option, "\"."));
737 return false;
738 }
739 } else if (option == "CASE") {
740 if (sortConfig.Case != SortConfig::CaseSensitivity::DEFAULT) {
741 status.SetError(cmStrCat(messageHint, "option \"", option,
742 "\" has been specified multiple times."));
743 return false;
744 }
745 if (argumentIndex < args.size()) {
746 std::string const& argument = args[argumentIndex++];
747 if (argument == "SENSITIVE") {
748 sortConfig.Case = SortConfig::CaseSensitivity::SENSITIVE;
749 } else if (argument == "INSENSITIVE") {
750 sortConfig.Case = SortConfig::CaseSensitivity::INSENSITIVE;
751 } else {
752 status.SetError(cmStrCat(messageHint, "value \"", argument,

Callers

nothing calls this directly

Calls 7

to_stringMethod · 0.80
cmStrCatFunction · 0.70
GetListFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
AddDefinitionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…