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

Method Generate

Source/cmNinjaNormalTargetGenerator.cxx:65–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() = default;
64
65void cmNinjaNormalTargetGenerator::Generate(std::string const& config)
66{
67 if (this->GetGeneratorTarget()->GetType() !=
68 cmStateEnums::INTERFACE_LIBRARY) {
69 std::string lang = this->GeneratorTarget->GetLinkerLanguage(config);
70 if (this->TargetLinkLanguage(config).empty()) {
71 cmSystemTools::Error(
72 cmStrCat("CMake can not determine linker language for target: ",
73 this->GetGeneratorTarget()->GetName()));
74 return;
75 }
76 }
77
78 // Write the rules for each language.
79 this->WriteLanguagesRules(config);
80
81 // Write the build statements
82 bool firstForConfig = true;
83 for (auto const& fileConfig : this->GetConfigNames()) {
84 if (!this->GetGlobalGenerator()
85 ->GetCrossConfigs(fileConfig)
86 .count(config)) {
87 continue;
88 }
89 this->WriteObjectBuildStatements(config, fileConfig, firstForConfig);
90 firstForConfig = false;
91 }
92
93 if (this->GetGeneratorTarget()->GetType() == cmStateEnums::OBJECT_LIBRARY) {
94 this->WriteObjectLibStatement(config);
95 } else if (this->GetGeneratorTarget()->GetType() ==
96 cmStateEnums::INTERFACE_LIBRARY) {
97 bool haveCxxModuleSources = false;
98 if (this->GetGeneratorTarget()->HaveCxx20ModuleSources()) {
99 haveCxxModuleSources = true;
100 }
101
102 if (!haveCxxModuleSources) {
103 cmSystemTools::Error(cmStrCat(
104 "Ninja does not support INTERFACE libraries without C++ module "
105 "sources as a normal target: ",
106 this->GetGeneratorTarget()->GetName()));
107 return;
108 }
109
110 firstForConfig = true;
111 for (auto const& fileConfig : this->GetConfigNames()) {
112 if (!this->GetGlobalGenerator()
113 ->GetCrossConfigs(fileConfig)
114 .count(config)) {
115 continue;
116 }
117 if (haveCxxModuleSources) {
118 this->WriteCxxModuleLibraryStatement(config, fileConfig,
119 firstForConfig);
120 }
121 firstForConfig = false;
122 }

Callers

nothing calls this directly

Calls 15

TargetLinkLanguageMethod · 0.95
WriteLanguagesRulesMethod · 0.95
WriteLinkStatementMethod · 0.95
GetCrossConfigsMethod · 0.80
AddTargetAliasMethod · 0.80
ErrorClass · 0.70

Tested by

no test coverage detected