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

Method ParseGeneratorToolset

Source/cmGlobalXCodeGenerator.cxx:387–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387bool cmGlobalXCodeGenerator::ParseGeneratorToolset(std::string const& ts,
388 cmMakefile* mf)
389{
390 std::vector<std::string> const fields =
391 cmTokenize(ts, ',', cmTokenizerMode::New);
392 if (fields.empty()) {
393 return true;
394 }
395
396 auto fi = fields.cbegin();
397 // The first field may be the Xcode GCC_VERSION.
398 if (fi->find('=') == fi->npos) {
399 this->GeneratorToolset = *fi;
400 ++fi;
401 }
402
403 std::unordered_set<std::string> handled;
404
405 // The rest of the fields must be key=value pairs.
406 for (; fi != fields.cend(); ++fi) {
407 std::string::size_type pos = fi->find('=');
408 if (pos == fi->npos) {
409 /* clang-format off */
410 std::string const& e = cmStrCat(
411 "Generator\n"
412 " ", this->GetName(), "\n"
413 "given toolset specification\n"
414 " ", ts, "\n"
415 "that contains a field after the first ',' with no '='."
416 );
417 /* clang-format on */
418 mf->IssueMessage(MessageType::FATAL_ERROR, e);
419 return false;
420 }
421 std::string const key = fi->substr(0, pos);
422 std::string const value = fi->substr(pos + 1);
423 if (!handled.insert(key).second) {
424 /* clang-format off */
425 std::string const& e = cmStrCat(
426 "Generator\n"
427 " ", this->GetName(), "\n"
428 "given toolset specification\n"
429 " ", ts, "\n"
430 "that contains duplicate field key '", key, "'."
431 );
432 /* clang-format on */
433 mf->IssueMessage(MessageType::FATAL_ERROR, e);
434 return false;
435 }
436 if (!this->ProcessGeneratorToolsetField(key, value, mf)) {
437 return false;
438 }
439 }
440
441 return true;
442}
443
444bool cmGlobalXCodeGenerator::ProcessGeneratorToolsetField(

Callers 1

SetGeneratorToolsetMethod · 0.95

Calls 11

GetNameMethod · 0.95
cmTokenizeFunction · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
findMethod · 0.45
IssueMessageMethod · 0.45
substrMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected