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

Function HandleSourceMode

Source/cmGetPropertyCommand.cxx:462–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462bool HandleSourceMode(cmExecutionStatus& status, std::string const& name,
463 OutType infoType, std::string const& variable,
464 std::string const& propertyName,
465 cmMakefile& directory_makefile,
466 bool const source_file_paths_should_be_absolute)
467{
468 if (name.empty()) {
469 status.SetError("not given name for SOURCE scope.");
470 return false;
471 }
472
473 // Special handling for GENERATED property.
474 // Note: Only, if CMP0163 is set to NEW!
475 if (propertyName == "GENERATED"_s) {
476 auto& mf = status.GetMakefile();
477 auto cmp0163 = directory_makefile.GetPolicyStatus(cmPolicies::CMP0163);
478 bool const cmp0163new =
479 cmp0163 != cmPolicies::OLD && cmp0163 != cmPolicies::WARN;
480 if (cmp0163new) {
481 return GetPropertyCommand::GetSourceFilePropertyGENERATED(
482 name, mf, [infoType, &variable, &mf](bool isGenerated) -> bool {
483 // Set the value on the original Makefile scope, not the scope of the
484 // requested directory.
485 return StoreResult(infoType, mf, variable,
486 (isGenerated) ? cmValue("1") : cmValue("0"));
487 });
488 }
489 }
490
491 // Get the source file.
492 std::string const source_file_absolute_path =
493 SetPropertyCommand::MakeSourceFilePathAbsoluteIfNeeded(
494 status, name, source_file_paths_should_be_absolute);
495 if (cmSourceFile* sf =
496 directory_makefile.GetOrCreateSource(source_file_absolute_path)) {
497 // Set the value on the original Makefile scope, not the scope of the
498 // requested directory.
499 return StoreResult(infoType, status.GetMakefile(), variable,
500 sf->GetPropertyForUser(propertyName));
501 }
502 status.SetError(
503 cmStrCat("given SOURCE name that could not be found or created: ",
504 source_file_absolute_path));
505 return false;
506}
507
508bool HandleTestMode(cmExecutionStatus& status, std::string const& name,
509 OutType infoType, std::string const& variable,

Callers 1

cmGetPropertyCommandFunction · 0.70

Calls 11

GetOrCreateSourceMethod · 0.80
GetPropertyForUserMethod · 0.80
StoreResultFunction · 0.70
cmValueClass · 0.70
cmStrCatFunction · 0.70
emptyMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
GetPolicyStatusMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…