| 575 | } |
| 576 | |
| 577 | void cmInstallTargetGenerator::AddInstallNamePatchRule( |
| 578 | std::ostream& os, Indent indent, std::string const& config, |
| 579 | std::string const& toDestDirPath) |
| 580 | { |
| 581 | if (this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly || |
| 582 | !(this->Target->GetType() == cmStateEnums::SHARED_LIBRARY || |
| 583 | this->Target->GetType() == cmStateEnums::MODULE_LIBRARY || |
| 584 | this->Target->GetType() == cmStateEnums::EXECUTABLE)) { |
| 585 | return; |
| 586 | } |
| 587 | |
| 588 | // Fix the install_name settings in installed binaries. |
| 589 | std::string installNameTool = |
| 590 | this->Target->Target->GetMakefile()->GetSafeDefinition( |
| 591 | "CMAKE_INSTALL_NAME_TOOL"); |
| 592 | |
| 593 | if (installNameTool.empty()) { |
| 594 | return; |
| 595 | } |
| 596 | |
| 597 | // Build a map of build-tree install_name to install-tree install_name for |
| 598 | // shared libraries linked to this target. |
| 599 | std::map<std::string, std::string> install_name_remap; |
| 600 | if (cmComputeLinkInformation* cli = |
| 601 | this->Target->GetLinkInformation(config)) { |
| 602 | std::set<cmGeneratorTarget const*> const& sharedLibs = |
| 603 | cli->GetSharedLibrariesLinked(); |
| 604 | for (cmGeneratorTarget const* tgt : sharedLibs) { |
| 605 | // The install_name of an imported target does not change. |
| 606 | if (tgt->IsImported()) { |
| 607 | continue; |
| 608 | } |
| 609 | |
| 610 | // If the build tree and install tree use different path |
| 611 | // components of the install_name field then we need to create a |
| 612 | // mapping to be applied after installation. |
| 613 | std::string for_build = tgt->GetInstallNameDirForBuildTree(config); |
| 614 | std::string for_install = tgt->GetInstallNameDirForInstallTree( |
| 615 | config, "${CMAKE_INSTALL_PREFIX}"); |
| 616 | if (for_build != for_install) { |
| 617 | // The directory portions differ. Append the filename to |
| 618 | // create the mapping. |
| 619 | std::string fname = this->GetInstallFilename(tgt, config, NameSO); |
| 620 | |
| 621 | // Map from the build-tree install_name. |
| 622 | for_build += fname; |
| 623 | |
| 624 | // Map to the install-tree install_name. |
| 625 | for_install += fname; |
| 626 | |
| 627 | // Store the mapping entry. |
| 628 | install_name_remap[for_build] = for_install; |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | // Edit the install_name of the target itself if necessary. |
| 634 | std::string new_id; |
no test coverage detected