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

Method Evaluate

Source/cmGeneratorExpressionNode.cxx:3459–3518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3457 int NumExpectedParameters() const override { return OneOrMoreParameters; }
3458
3459 std::string Evaluate(
3460 std::vector<std::string> const& parameters, cm::GenEx::Evaluation* eval,
3461 GeneratorExpressionContent const* content,
3462 cmGeneratorExpressionDAGChecker* dagChecker) const override
3463 {
3464 using ForGenex = cmGeneratorExpressionDAGChecker::ForGenex;
3465
3466 if (!eval->HeadTarget || !dagChecker ||
3467 !dagChecker->EvaluatingLinkLibraries(nullptr, ForGenex::LINK_GROUP)) {
3468 reportError(
3469 eval, content->GetOriginalExpression(),
3470 "$<LINK_GROUP:...> may only be used with binary targets "
3471 "to specify group of link libraries through 'LINK_LIBRARIES', "
3472 "'INTERFACE_LINK_LIBRARIES', and "
3473 "'INTERFACE_LINK_LIBRARIES_DIRECT' properties.");
3474 return std::string();
3475 }
3476
3477 cmList list{ parameters.begin(), parameters.end() };
3478 if (list.empty()) {
3479 reportError(
3480 eval, content->GetOriginalExpression(),
3481 "$<LINK_GROUP:...> expects a feature name as first argument.");
3482 return std::string();
3483 }
3484 // $<LINK_GROUP:..> cannot be nested
3485 if (std::find_if(list.cbegin(), list.cend(),
3486 [](std::string const& item) -> bool {
3487 return cmHasPrefix(item, "<LINK_GROUP"_s);
3488 }) != list.cend()) {
3489 reportError(eval, content->GetOriginalExpression(),
3490 "$<LINK_GROUP:...> cannot be nested.");
3491 return std::string();
3492 }
3493 if (list.size() == 1) {
3494 // no libraries specified, ignore this genex
3495 return std::string();
3496 }
3497
3498 static cmsys::RegularExpression featureNameValidator("^[A-Za-z0-9_]+$");
3499 auto const& feature = list.front();
3500 if (!featureNameValidator.find(feature)) {
3501 reportError(eval, content->GetOriginalExpression(),
3502 cmStrCat("The feature name '", feature,
3503 "' contains invalid characters."));
3504 return std::string();
3505 }
3506
3507 auto const LG_BEGIN = cmStrCat(
3508 "<LINK_GROUP:", feature, ':',
3509 cmJoin(cmRange<decltype(list.cbegin())>(list.cbegin() + 1, list.cend()),
3510 "|"_s),
3511 '>');
3512 auto const LG_END = cmStrCat("</LINK_GROUP:", feature, '>');
3513
3514 list.front() = LG_BEGIN;
3515 list.push_back(LG_END);
3516

Callers

nothing calls this directly

Calls 15

reportErrorFunction · 0.85
cmHasPrefixFunction · 0.85
GetOriginalExpressionMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
push_backMethod · 0.80
to_stringMethod · 0.80
cmStrCatFunction · 0.70
cmJoinFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected