| 1231 | } |
| 1232 | |
| 1233 | cmTarget* cmMakefile::AddUtilityCommand(std::string const& utilityName, |
| 1234 | bool excludeFromAll, |
| 1235 | std::unique_ptr<cmCustomCommand> cc) |
| 1236 | { |
| 1237 | auto const& depends = cc->GetDepends(); |
| 1238 | auto const& byproducts = cc->GetByproducts(); |
| 1239 | auto const& commandLines = cc->GetCommandLines(); |
| 1240 | cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll); |
| 1241 | |
| 1242 | // Validate custom commands. |
| 1243 | if ((commandLines.empty() && depends.empty()) || |
| 1244 | !this->ValidateCustomCommand(commandLines)) { |
| 1245 | return target; |
| 1246 | } |
| 1247 | |
| 1248 | // Always create the byproduct sources and mark them generated. |
| 1249 | this->CreateGeneratedOutputs(byproducts); |
| 1250 | |
| 1251 | cc->RecordPolicyValues(this->GetStateSnapshot()); |
| 1252 | |
| 1253 | // Dispatch command creation to allow generator expressions in outputs. |
| 1254 | this->AddGeneratorAction( |
| 1255 | std::move(cc), |
| 1256 | [this, target](cmLocalGenerator& lg, cmListFileBacktrace const& lfbt, |
| 1257 | std::unique_ptr<cmCustomCommand> tcc) { |
| 1258 | BacktraceGuard guard(this->Backtrace, lfbt); |
| 1259 | tcc->SetBacktrace(lfbt); |
| 1260 | detail::AddUtilityCommand(lg, cmCommandOrigin::Project, target, |
| 1261 | std::move(tcc)); |
| 1262 | }); |
| 1263 | |
| 1264 | return target; |
| 1265 | } |
| 1266 | |
| 1267 | static void s_AddDefineFlag(std::string const& flag, std::string& dflags) |
| 1268 | { |
no test coverage detected