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

Method AppendLinkDeps

Source/cmFastbuildNormalTargetGenerator.cxx:2058–2149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2056}
2057
2058void cmFastbuildNormalTargetGenerator::AppendLinkDeps(
2059 std::set<FastbuildTargetDep>& preBuildDeps, FastbuildLinkerNode& linkerNode,
2060 FastbuildLinkerNode& cudaDeviceLinkLinkerNode)
2061{
2062 std::set<std::string> linkedObjects;
2063 cmComputeLinkInformation const* linkInfo =
2064 this->GeneratorTarget->GetLinkInformation(Config);
2065 if (!linkInfo) {
2066 return;
2067 }
2068
2069 UsingCommandLine = false;
2070 AppendLINK_DEPENDS(linkerNode);
2071 // Object libs that are linked directly to target (e.g.
2072 // add_executable(test_exe archiveObjs)
2073 AppendDirectObjectLibs(linkerNode, linkedObjects);
2074 std::size_t numberOfDirectlyLinkedObjects =
2075 linkerNode.LibrarianAdditionalInputs.size();
2076 // target_link_libraries.
2077 cmComputeLinkInformation::ItemVector const items = linkInfo->GetItems();
2078
2079 LogMessage(cmStrCat("Link items size: ", items.size()));
2080 for (cmComputeLinkInformation::Item const& item : items) {
2081 std::string const feature = item.GetFeatureName();
2082 LogMessage("GetFeatureName: " + feature);
2083 std::string const formatted =
2084 item.GetFormattedItem(item.Value.Value).Value;
2085 if (!feature.empty()) {
2086 LogMessage("GetFormattedItem: " +
2087 item.GetFormattedItem(item.Value.Value).Value);
2088 }
2089 // We're linked to `$<TARGET_OBJECTS>`.
2090 // Static libs transitively propagate such deps, see:
2091 // https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries-via-target-objects
2092 if (item.ObjectSource &&
2093 linkerNode.Type != FastbuildLinkerNode::STATIC_LIBRARY) {
2094 // Tested in "ObjectLibrary" test.
2095 std::string const libName = item.ObjectSource->GetObjectLibrary();
2096 std::string dep = libName + FASTBUILD_OBJECTS_ALIAS_POSTFIX;
2097 if (linkedObjects.emplace(dep).second) {
2098 FastbuildTargetDep targetDep{ libName };
2099 targetDep.Type = FastbuildTargetDepType::ORDER_ONLY;
2100 preBuildDeps.emplace(std::move(targetDep));
2101
2102 cmTarget const* importedTarget =
2103 this->LocalGenerator->GetMakefile()->FindImportedTarget(libName);
2104 // Add direct path to the object for imported target
2105 // since such targets are not defined in fbuild.bff file.
2106 if (importedTarget) {
2107 LogMessage(
2108 cmStrCat("Adding ", formatted, " to LibrarianAdditionalInputs"));
2109 linkerNode.LibrarianAdditionalInputs.emplace_back(formatted);
2110 } else {
2111 LogMessage(
2112 cmStrCat("Adding ", dep, " to LibrarianAdditionalInputs"));
2113 linkerNode.LibrarianAdditionalInputs.emplace_back(std::move(dep));
2114 }
2115 }

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
GetLinkInformationMethod · 0.80
GetItemsMethod · 0.80
GetFormattedItemMethod · 0.80
GetObjectLibraryMethod · 0.80
emplaceMethod · 0.80
FindImportedTargetMethod · 0.80
emplace_backMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70
swapFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected