| 1341 | } |
| 1342 | |
| 1343 | bool cmMakefileTargetGenerator::WriteMakeRule( |
| 1344 | std::ostream& os, char const* comment, |
| 1345 | std::vector<std::string> const& outputs, |
| 1346 | std::vector<std::string> const& depends, |
| 1347 | std::vector<std::string> const& commands, bool in_help) |
| 1348 | { |
| 1349 | bool symbolic = false; |
| 1350 | if (outputs.empty()) { |
| 1351 | return symbolic; |
| 1352 | } |
| 1353 | |
| 1354 | // Check whether we need to bother checking for a symbolic output. |
| 1355 | bool const need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); |
| 1356 | |
| 1357 | // Check whether the first output is marked as symbolic. |
| 1358 | if (need_symbolic) { |
| 1359 | if (cmSourceFile* sf = this->Makefile->GetSource(outputs[0])) { |
| 1360 | symbolic = sf->GetPropertyAsBool("SYMBOLIC"); |
| 1361 | } |
| 1362 | } |
| 1363 | |
| 1364 | // We always attach the actual commands to the first output. |
| 1365 | this->LocalGenerator->WriteMakeRule(os, comment, outputs[0], depends, |
| 1366 | commands, symbolic, in_help); |
| 1367 | |
| 1368 | // For single outputs, we are done. |
| 1369 | if (outputs.size() == 1) { |
| 1370 | return symbolic; |
| 1371 | } |
| 1372 | |
| 1373 | // For multiple outputs, make the extra ones depend on the first one. |
| 1374 | std::vector<std::string> const output_depends(1, outputs[0]); |
| 1375 | for (std::string const& output : cmMakeRange(outputs).advance(1)) { |
| 1376 | // Touch the extra output so "make" knows that it was updated, |
| 1377 | // but only if the output was actually created. |
| 1378 | std::string const out = this->LocalGenerator->ConvertToOutputFormat( |
| 1379 | this->LocalGenerator->MaybeRelativeToTopBinDir(output), |
| 1380 | cmOutputConverter::SHELL); |
| 1381 | std::vector<std::string> output_commands; |
| 1382 | |
| 1383 | bool o_symbolic = false; |
| 1384 | if (need_symbolic) { |
| 1385 | if (cmSourceFile const* sf = this->Makefile->GetSource(output)) { |
| 1386 | o_symbolic = sf->GetPropertyAsBool("SYMBOLIC"); |
| 1387 | } |
| 1388 | } |
| 1389 | symbolic = symbolic && o_symbolic; |
| 1390 | |
| 1391 | if (!o_symbolic) { |
| 1392 | output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out); |
| 1393 | } |
| 1394 | this->LocalGenerator->WriteMakeRule(os, nullptr, output, output_depends, |
| 1395 | output_commands, o_symbolic, in_help); |
| 1396 | |
| 1397 | if (!o_symbolic) { |
| 1398 | // At build time, remove the first output if this one does not exist |
| 1399 | // so that "make" will rerun the real commands that create this one. |
| 1400 | MultipleOutputPairsType::value_type p(output, outputs[0]); |
no test coverage detected