| 134 | } |
| 135 | |
| 136 | bool cmParseArgumentsCommand(std::vector<std::string> const& args, |
| 137 | cmExecutionStatus& status) |
| 138 | { |
| 139 | // cmake_parse_arguments(prefix options single multi <ARGN>) |
| 140 | // 1 2 3 4 |
| 141 | // or |
| 142 | // cmake_parse_arguments(PARSE_ARGV N prefix options single multi) |
| 143 | if (args.size() < 4) { |
| 144 | status.SetError("must be called with at least 4 arguments."); |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | auto argIter = args.begin(); |
| 149 | auto argEnd = args.end(); |
| 150 | bool parseFromArgV = false; |
| 151 | unsigned long argvStart = 0; |
| 152 | if (*argIter == "PARSE_ARGV") { |
| 153 | if (args.size() != 6) { |
| 154 | status.GetMakefile().IssueMessage( |
| 155 | MessageType::FATAL_ERROR, |
| 156 | "PARSE_ARGV must be called with exactly 6 arguments."); |
| 157 | cmSystemTools::SetFatalErrorOccurred(); |
| 158 | return true; |
| 159 | } |
| 160 | parseFromArgV = true; |
| 161 | argIter++; // move past PARSE_ARGV |
| 162 | if (!cmStrToULong(*argIter, &argvStart)) { |
| 163 | status.GetMakefile().IssueMessage( |
| 164 | MessageType::FATAL_ERROR, |
| 165 | cmStrCat("PARSE_ARGV index '", *argIter, |
| 166 | "' is not an unsigned integer")); |
| 167 | cmSystemTools::SetFatalErrorOccurred(); |
| 168 | return true; |
| 169 | } |
| 170 | argIter++; // move past N |
| 171 | } |
| 172 | // the first argument is the prefix |
| 173 | std::string const prefix = (*argIter++) + "_"; |
| 174 | |
| 175 | UserArgumentParser parser; |
| 176 | |
| 177 | // define the result maps holding key/value pairs for |
| 178 | // options, single values and multi values |
| 179 | options_map options; |
| 180 | single_map singleValArgs; |
| 181 | multi_map multiValArgs; |
| 182 | |
| 183 | // anything else is put into a vector of unparsed strings |
| 184 | std::vector<std::string> unparsed; |
| 185 | |
| 186 | auto const duplicateKey = [&status](std::string const& key) { |
| 187 | status.GetMakefile().IssueMessage( |
| 188 | MessageType::WARNING, cmStrCat("keyword defined more than once: ", key)); |
| 189 | }; |
| 190 | |
| 191 | // the second argument is a (cmake) list of options without argument |
| 192 | cmList list{ *argIter++ }; |
| 193 | parser.Bind(list, options, duplicateKey); |
nothing calls this directly
no test coverage detected
searching dependent graphs…