| 671 | } |
| 672 | |
| 673 | void cmInstallTargetGenerator::AddRPathCheckRule( |
| 674 | std::ostream& os, Indent indent, std::string const& config, |
| 675 | std::string const& toDestDirPath) |
| 676 | { |
| 677 | // Skip the chrpath if the target does not need it. |
| 678 | if (this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly || |
| 679 | !this->Target->IsChrpathUsed(config)) { |
| 680 | return; |
| 681 | } |
| 682 | // Skip if on Apple |
| 683 | if (this->Target->Target->GetMakefile()->IsOn( |
| 684 | "CMAKE_PLATFORM_HAS_INSTALLNAME")) { |
| 685 | return; |
| 686 | } |
| 687 | |
| 688 | // Get the link information for this target. |
| 689 | // It can provide the RPATH. |
| 690 | cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); |
| 691 | if (!cli) { |
| 692 | return; |
| 693 | } |
| 694 | |
| 695 | // Write a rule to remove the installed file if its rpath is not the |
| 696 | // new rpath. This is needed for existing build/install trees when |
| 697 | // the installed rpath changes but the file is not rebuilt. |
| 698 | os << indent << "file(RPATH_CHECK\n" |
| 699 | << indent << " FILE \"" << toDestDirPath << "\"\n"; |
| 700 | |
| 701 | // CMP0095: ``RPATH`` entries are properly escaped in the intermediary |
| 702 | // CMake install script. |
| 703 | switch (this->Target->GetPolicyStatusCMP0095()) { |
| 704 | case cmPolicies::WARN: |
| 705 | // No author warning needed here, we warn later in |
| 706 | // cmInstallTargetGenerator::AddChrpathPatchRule(). |
| 707 | CM_FALLTHROUGH; |
| 708 | case cmPolicies::OLD: { |
| 709 | // Get the install RPATH from the link information. |
| 710 | std::string newRpath = cli->GetChrpathString(); |
| 711 | os << indent << " RPATH \"" << newRpath << "\")\n"; |
| 712 | break; |
| 713 | } |
| 714 | default: { |
| 715 | // Get the install RPATH from the link information and |
| 716 | // escape any CMake syntax in the install RPATH. |
| 717 | std::string escapedNewRpath = |
| 718 | cmOutputConverter::EscapeForCMake(cli->GetChrpathString()); |
| 719 | os << indent << " RPATH " << escapedNewRpath << ")\n"; |
| 720 | break; |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | void cmInstallTargetGenerator::AddChrpathPatchRule( |
| 726 | std::ostream& os, Indent indent, std::string const& config, |
no test coverage detected