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

Method AddTarget

Source/cmGlobalFastbuildGenerator.h:555–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553
554 template <class T>
555 void AddTarget(T target)
556 {
557 // Sometimes equivalent CCs are added to different targets. We try to
558 // de-dup it by assigning all execs a name which is a hash computed based
559 // on various properties (like input, output, deps.). Apparently, there are
560 // still some CCs intersection between different targets.
561 auto val = AllGeneratedCommands.emplace(target.Name);
562 if (val.second) {
563 FastbuildTargets.emplace_back(cm::make_unique<T>(std::move(target)));
564 }
565 // Get the intersection of CC's deps. Just mimicking what
566 // cmLocalNinjaGenerator::WriteCustomCommandBuildStatement does. (I don't
567 // think it's right in general case, each CC should be added only to 1
568 // target, not to multiple )
569 else {
570 auto it =
571 std::find_if(FastbuildTargets.begin(), FastbuildTargets.end(),
572 [&target](FastbuildTargetPtrT const& existingTarget) {
573 return existingTarget->Name == target.Name;
574 });
575 assert(it != FastbuildTargets.end());
576
577 std::set<FastbuildTargetDep> intersection;
578 std::set_intersection(
579 target.PreBuildDependencies.begin(), target.PreBuildDependencies.end(),
580 (*it)->PreBuildDependencies.begin(), (*it)->PreBuildDependencies.end(),
581 std::inserter(intersection, intersection.end()));
582 (*it)->PreBuildDependencies = std::move(intersection);
583 }
584 }
585
586 static std::string GetExternalShellExecutable();
587 std::string GetTargetName(cmGeneratorTarget const* GeneratorTarget) const;

Callers 5

AddTargetAllMethod · 0.95
AddGlobCheckExecMethod · 0.95
GenerateMethod · 0.80
GenerateCommandsMethod · 0.80
GenerateMethod · 0.80

Calls 5

moveFunction · 0.85
emplaceMethod · 0.80
emplace_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected