| 1172 | } |
| 1173 | |
| 1174 | void cmMakefile::AddCustomCommandToOutput( |
| 1175 | std::unique_ptr<cmCustomCommand> cc, CommandSourceCallback const& callback, |
| 1176 | bool replace) |
| 1177 | { |
| 1178 | auto const& outputs = cc->GetOutputs(); |
| 1179 | auto const& byproducts = cc->GetByproducts(); |
| 1180 | auto const& commandLines = cc->GetCommandLines(); |
| 1181 | |
| 1182 | // Make sure there is at least one output. |
| 1183 | if (outputs.empty()) { |
| 1184 | cmSystemTools::Error("Attempt to add a custom rule with no output!"); |
| 1185 | return; |
| 1186 | } |
| 1187 | |
| 1188 | // Validate custom commands. |
| 1189 | if (!this->ValidateCustomCommand(commandLines)) { |
| 1190 | return; |
| 1191 | } |
| 1192 | |
| 1193 | // Always create the output sources and mark them generated. |
| 1194 | this->CreateGeneratedOutputs(outputs); |
| 1195 | this->CreateGeneratedOutputs(byproducts); |
| 1196 | |
| 1197 | cc->RecordPolicyValues(this->GetStateSnapshot()); |
| 1198 | |
| 1199 | // Dispatch command creation to allow generator expressions in outputs. |
| 1200 | this->AddGeneratorAction( |
| 1201 | std::move(cc), |
| 1202 | [this, replace, callback](cmLocalGenerator& lg, |
| 1203 | cmListFileBacktrace const& lfbt, |
| 1204 | std::unique_ptr<cmCustomCommand> tcc) { |
| 1205 | BacktraceGuard guard(this->Backtrace, lfbt); |
| 1206 | tcc->SetBacktrace(lfbt); |
| 1207 | cmSourceFile* sf = detail::AddCustomCommandToOutput( |
| 1208 | lg, cmCommandOrigin::Project, std::move(tcc), replace); |
| 1209 | if (callback && sf) { |
| 1210 | callback(sf); |
| 1211 | } |
| 1212 | }); |
| 1213 | } |
| 1214 | |
| 1215 | void cmMakefile::AppendCustomCommandToOutput( |
| 1216 | std::string const& output, std::vector<std::string> const& depends, |
no test coverage detected