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

Method WriteMainCMakefile

Source/cmGlobalUnixMakefileGenerator3.cxx:240–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
241{
242 if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
243 return;
244 }
245
246 // Open the output file. This should not be copy-if-different
247 // because the check-build-system step compares the makefile time to
248 // see if the build system must be regenerated.
249 std::string cmakefileName =
250 cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
251 "/CMakeFiles/Makefile.cmake");
252 cmGeneratedFileStream cmakefileStream(cmakefileName);
253 if (!cmakefileStream) {
254 return;
255 }
256
257 std::string makefileName =
258 cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(), "/Makefile");
259
260 {
261 // get a local generator for some useful methods
262 auto& lg = cm::static_reference_cast<cmLocalUnixMakefileGenerator3>(
263 this->LocalGenerators[0]);
264
265 // Write the do not edit header.
266 lg.WriteDisclaimer(cmakefileStream);
267 }
268
269 // Save the generator name
270 cmakefileStream << "# The generator used is:\n"
271 << "set(CMAKE_DEPENDS_GENERATOR \"" << this->GetName()
272 << "\")\n\n";
273
274 // for each cmMakefile get its list of dependencies
275 std::vector<std::string> lfiles;
276 for (auto const& localGen : this->LocalGenerators) {
277 // Get the list of files contributing to this generation step.
278 cm::append(lfiles, localGen->GetMakefile()->GetListFiles());
279 }
280
281 cmake* cm = this->GetCMakeInstance();
282 if (cm->DoWriteGlobVerifyTarget()) {
283 lfiles.push_back(cm->GetGlobVerifyScript());
284 lfiles.push_back(cm->GetGlobVerifyStamp());
285 }
286
287 // Sort the list and remove duplicates.
288 std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
289#if !defined(__VMS) // The Compaq STL on VMS crashes, so accept duplicates.
290 auto new_end = std::unique(lfiles.begin(), lfiles.end());
291 lfiles.erase(new_end, lfiles.end());
292#endif
293
294 {
295 // reset lg to the first makefile
296 auto const& lg = cm::static_reference_cast<cmLocalUnixMakefileGenerator3>(
297 this->LocalGenerators[0]);

Callers 1

GenerateMethod · 0.95

Calls 15

GetNameMethod · 0.95
appendFunction · 0.85
GlobalSettingIsOnMethod · 0.80
push_backMethod · 0.80
eraseMethod · 0.80
cmStrCatFunction · 0.70
GetCMakeInstanceMethod · 0.45
WriteDisclaimerMethod · 0.45
GetMakefileMethod · 0.45

Tested by

no test coverage detected