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

Method WriteDependencies

Source/cmDependsCompiler.cxx:187–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void cmDependsCompiler::WriteDependencies(
188 cmDepends::DependencyMap const& dependencies, std::ostream& makeDepends,
189 std::ostream& internalDepends)
190{
191 // dependencies file consumed by make tool
192 auto const& lineContinue = static_cast<cmGlobalUnixMakefileGenerator3*>(
193 this->LocalGenerator->GetGlobalGenerator())
194 ->LineContinueDirective;
195 bool supportLongLineDepend = static_cast<cmGlobalUnixMakefileGenerator3*>(
196 this->LocalGenerator->GetGlobalGenerator())
197 ->SupportsLongLineDependencies();
198 cmDepends::DependencyMap makeDependencies(dependencies);
199 std::unordered_set<cm::string_view> phonyTargets;
200
201 // external dependencies file
202 for (auto& node : makeDependencies) {
203 auto target = this->LocalGenerator->ConvertToMakefilePath(
204 this->LocalGenerator->MaybeRelativeToTopBinDir(node.first));
205 auto& deps = node.second;
206 std::transform(deps.cbegin(), deps.cend(), deps.begin(),
207 [this](std::string const& dep) {
208 return this->LocalGenerator->ConvertToMakefilePath(
209 this->LocalGenerator->MaybeRelativeToTopBinDir(dep));
210 });
211
212 bool first_dep = true;
213 if (supportLongLineDepend) {
214 makeDepends << target << ": ";
215 }
216 for (auto const& dep : deps) {
217 if (supportLongLineDepend) {
218 if (first_dep) {
219 first_dep = false;
220 makeDepends << dep;
221 } else {
222 makeDepends << ' ' << lineContinue << " " << dep;
223 }
224 } else {
225 makeDepends << target << ": " << dep << std::endl;
226 }
227
228 phonyTargets.emplace(dep.data(), dep.length());
229 }
230 makeDepends << std::endl << std::endl;
231 }
232
233 // add phony targets
234 for (auto const& target : phonyTargets) {
235 makeDepends << std::endl << target << ':' << std::endl;
236 }
237
238 // internal dependencies file
239 for (auto const& node : dependencies) {
240 internalDepends << node.first << std::endl;
241 for (auto const& dep : node.second) {
242 internalDepends << ' ' << dep << std::endl;
243 }
244 internalDepends << std::endl;

Callers

nothing calls this directly

Calls 11

transformFunction · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
emplaceMethod · 0.80
lengthMethod · 0.80
GetGlobalGeneratorMethod · 0.45
ConvertToMakefilePathMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected