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

Method Evaluate

Source/cmGeneratorExpressionNode.cxx:4273–4343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4271 TargetObjectsNode() {} // NOLINT(modernize-use-equals-default)
4272
4273 std::string Evaluate(
4274 std::vector<std::string> const& parameters, cm::GenEx::Evaluation* eval,
4275 GeneratorExpressionContent const* content,
4276 cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
4277 {
4278 std::string const& tgtName = parameters.front();
4279 cmGeneratorTarget* gt =
4280 eval->Context.LG->FindGeneratorTargetToUse(tgtName);
4281 if (!gt) {
4282 std::ostringstream e;
4283 e << "Objects of target \"" << tgtName
4284 << "\" referenced but no such target exists.";
4285 reportError(eval, content->GetOriginalExpression(), e.str());
4286 return std::string();
4287 }
4288 cmStateEnums::TargetType type = gt->GetType();
4289 if (type != cmStateEnums::EXECUTABLE &&
4290 type != cmStateEnums::STATIC_LIBRARY &&
4291 type != cmStateEnums::SHARED_LIBRARY &&
4292 type != cmStateEnums::MODULE_LIBRARY &&
4293 type != cmStateEnums::OBJECT_LIBRARY) {
4294 std::ostringstream e;
4295 e << "Objects of target \"" << tgtName
4296 << "\" referenced but is not one of the allowed target types "
4297 << "(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT).";
4298 reportError(eval, content->GetOriginalExpression(), e.str());
4299 return std::string();
4300 }
4301 cmGlobalGenerator const* gg = eval->Context.LG->GetGlobalGenerator();
4302 if (!HasKnownObjectFileLocation(eval, content, "TARGET_OBJECTS", gt)) {
4303 return std::string();
4304 }
4305
4306 cmList objects;
4307
4308 if (gt->IsImported()) {
4309 cmValue loc = nullptr;
4310 cmValue imp = nullptr;
4311 std::string suffix;
4312 if (gt->Target->GetMappedConfig(eval->Context.Config, loc, imp,
4313 suffix)) {
4314 objects.assign(*loc);
4315 }
4316 eval->HadContextSensitiveCondition = true;
4317 } else {
4318 gt->GetTargetObjectNames(eval->Context.Config, objects);
4319
4320 std::string obj_dir;
4321 if (eval->EvaluateForBuildsystem && !gg->SupportsCrossConfigs()) {
4322 // Use object file directory with buildsystem placeholder.
4323 obj_dir = gt->ObjectDirectory;
4324 eval->HadContextSensitiveCondition = gt->HasContextDependentSources();
4325 } else {
4326 // Use object file directory with per-config location.
4327 obj_dir = gt->GetObjectDirectory(eval->Context.Config);
4328 eval->HadContextSensitiveCondition = true;
4329 }
4330

Callers

nothing calls this directly

Calls 15

reportErrorFunction · 0.85
GetOriginalExpressionMethod · 0.80
strMethod · 0.80
GetMappedConfigMethod · 0.80
assignMethod · 0.80
GetTargetObjectNamesMethod · 0.80
GetObjectDirectoryMethod · 0.80
AddTargetObjectMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected