| 567 | } |
| 568 | |
| 569 | void cmLocalUnixMakefileGenerator3::WriteMakeRule( |
| 570 | std::ostream& os, char const* comment, std::string const& target, |
| 571 | std::vector<std::string> const& depends, |
| 572 | std::vector<std::string> const& commands, bool symbolic, bool in_help) |
| 573 | { |
| 574 | // Make sure there is a target. |
| 575 | if (target.empty()) { |
| 576 | std::string err("No target for WriteMakeRule! called with comment: "); |
| 577 | if (comment) { |
| 578 | err += comment; |
| 579 | } |
| 580 | cmSystemTools::Error(err); |
| 581 | return; |
| 582 | } |
| 583 | |
| 584 | std::string replace; |
| 585 | |
| 586 | // Write the comment describing the rule in the makefile. |
| 587 | if (comment) { |
| 588 | replace = comment; |
| 589 | std::string::size_type lpos = 0; |
| 590 | std::string::size_type rpos; |
| 591 | while ((rpos = replace.find('\n', lpos)) != std::string::npos) { |
| 592 | os << "# " << replace.substr(lpos, rpos - lpos) << "\n"; |
| 593 | lpos = rpos + 1; |
| 594 | } |
| 595 | os << "# " << replace.substr(lpos) << "\n"; |
| 596 | } |
| 597 | |
| 598 | // Construct the left hand side of the rule. |
| 599 | std::string tgt = |
| 600 | this->ConvertToMakefilePath(this->MaybeRelativeToTopBinDir(target)); |
| 601 | |
| 602 | char const* space = ""; |
| 603 | if (tgt.size() == 1) { |
| 604 | // Add a space before the ":" to avoid drive letter confusion on |
| 605 | // Windows. |
| 606 | space = " "; |
| 607 | } |
| 608 | |
| 609 | // Mark the rule as symbolic if requested. |
| 610 | if (symbolic) { |
| 611 | if (cmValue sym = |
| 612 | this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) { |
| 613 | os << tgt << space << ": " << *sym << '\n'; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | // Write the rule. |
| 618 | if (depends.empty()) { |
| 619 | // No dependencies. The commands will always run. |
| 620 | os << tgt << space << ":\n"; |
| 621 | } else { |
| 622 | // Split dependencies into multiple rule lines. This allows for |
| 623 | // very long dependency lists even on older make implementations. |
| 624 | for (std::string const& depend : depends) { |
| 625 | os << tgt << space << ": " |
| 626 | << this->ConvertToMakefilePath(this->MaybeRelativeToTopBinDir(depend)) |
no test coverage detected