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

Method WriteLocalMakefile

Source/cmLocalUnixMakefileGenerator3.cxx:280–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
281{
282 // generate the includes
283 std::string ruleFileName = "Makefile";
284
285 // Open the rule file. This should be copy-if-different because the
286 // rules may depend on this file itself.
287 std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
288 cmGeneratedFileStream ruleFileStream(
289 ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
290 if (!ruleFileStream) {
291 return;
292 }
293 // always write the top makefile
294 if (!this->IsRootMakefile()) {
295 ruleFileStream.SetCopyIfDifferent(true);
296 }
297
298 // write the all rules
299 this->WriteLocalAllRules(ruleFileStream);
300
301 // only write local targets unless at the top Keep track of targets already
302 // listed.
303 std::set<std::string> emittedTargets;
304 if (!this->IsRootMakefile()) {
305 // write our targets, and while doing it collect up the object
306 // file rules
307 this->WriteLocalMakefileTargets(ruleFileStream, emittedTargets);
308 } else {
309 cmGlobalUnixMakefileGenerator3* gg =
310 static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
311 gg->WriteConvenienceRules(ruleFileStream, emittedTargets);
312 }
313
314 bool do_preprocess_rules = this->GetCreatePreprocessedSourceRules();
315 bool do_assembly_rules = this->GetCreateAssemblySourceRules();
316
317 std::map<std::string, LocalObjectInfo> localObjectFiles;
318 this->GetLocalObjectFiles(localObjectFiles);
319
320 // now write out the object rules
321 // for each object file name
322 for (auto& localObjectFile : localObjectFiles) {
323 // Add a convenience rule for building the object file.
324 this->WriteObjectConvenienceRule(
325 ruleFileStream, "target to build an object file", localObjectFile.first,
326 localObjectFile.second);
327
328 // Check whether preprocessing and assembly rules make sense.
329 // They make sense only for C and C++ sources.
330 bool lang_has_preprocessor = false;
331 bool lang_has_assembly = false;
332
333 for (LocalObjectEntry const& entry : localObjectFile.second) {
334 if (entry.Language == "C" || entry.Language == "CXX" ||
335 entry.Language == "CUDA" || entry.Language == "Fortran" ||
336 entry.Language == "HIP" || entry.Language == "ISPC") {
337 // Right now, C, C++, CUDA, Fortran, HIP and ISPC have both a

Callers 1

GenerateMethod · 0.95

Calls 15

ConvertToFullPathMethod · 0.95
WriteLocalAllRulesMethod · 0.95
GetLocalObjectFilesMethod · 0.95
SetCopyIfDifferentMethod · 0.80
WriteConvenienceRulesMethod · 0.80
rfindMethod · 0.80
WriteHelpRuleMethod · 0.80

Tested by

no test coverage detected