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

Method Generate

Source/cmGlobalNinjaGenerator.cxx:608–671  ·  view source on GitHub ↗

Implemented in all cmGlobaleGenerator sub-classes. Used in: Source/cmLocalGenerator.cxx Source/cmake.cxx

Source from the content-addressed store, hash-verified

606// Source/cmLocalGenerator.cxx
607// Source/cmake.cxx
608void cmGlobalNinjaGenerator::Generate()
609{
610 // Check minimum Ninja version.
611 if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion,
612 RequiredNinjaVersion())) {
613 std::ostringstream msg;
614 msg << "The detected version of Ninja (" << this->NinjaVersion;
615 msg << ") is less than the version of Ninja required by CMake (";
616 msg << cmGlobalNinjaGenerator::RequiredNinjaVersion() << ").";
617 this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
618 msg.str());
619 return;
620 }
621 this->InitOutputPathPrefix();
622 if (!this->OpenBuildFileStreams()) {
623 return;
624 }
625 if (!this->OpenRulesFileStream()) {
626 return;
627 }
628
629 for (auto& it : this->Configs) {
630 it.second.TargetDependsClosures.clear();
631 }
632
633 this->TargetAll = this->NinjaOutputPath("all");
634 this->CMakeCacheFile = this->NinjaOutputPath("CMakeCache.txt");
635 this->DiagnosedCxxModuleNinjaSupport = false;
636 this->ClangTidyExportFixesDirs.clear();
637 this->ClangTidyExportFixesFiles.clear();
638
639 this->cmGlobalGenerator::Generate();
640
641 this->WriteAssumedSourceDependencies();
642 this->WriteTargetAliases(*this->GetCommonFileStream());
643 this->WriteFolderTargets(*this->GetCommonFileStream());
644 this->WriteBuiltinTargets(*this->GetCommonFileStream());
645
646 if (cmSystemTools::GetErrorOccurredFlag()) {
647 this->RulesFileStream->setstate(std::ios::failbit);
648 for (std::string const& config : this->GetConfigNames()) {
649 this->GetImplFileStream(config)->setstate(std::ios::failbit);
650 this->GetConfigFileStream(config)->setstate(std::ios::failbit);
651 }
652 this->GetCommonFileStream()->setstate(std::ios::failbit);
653 }
654
655 this->CloseCompileCommandsStream();
656 this->CloseRulesFileStream();
657 this->CloseBuildFileStreams();
658
659#ifdef _WIN32
660 // Older ninja tools will not be able to update metadata on Windows
661 // when we are re-generating inside an existing 'ninja' invocation
662 // because the outer tool has the files open for write.
663 if (this->NinjaSupportsMetadataOnRegeneration ||
664 !this->GetCMakeInstance()->GetRegenerateDuringBuild())
665#endif

Callers

nothing calls this directly

Calls 15

InitOutputPathPrefixMethod · 0.95
OpenBuildFileStreamsMethod · 0.95
OpenRulesFileStreamMethod · 0.95
NinjaOutputPathMethod · 0.95
WriteTargetAliasesMethod · 0.95
GetCommonFileStreamMethod · 0.95
WriteFolderTargetsMethod · 0.95
WriteBuiltinTargetsMethod · 0.95
GetImplFileStreamMethod · 0.95
GetConfigFileStreamMethod · 0.95

Tested by

no test coverage detected