MCPcopy Create free account
hub / github.com/Kitware/CMake / AddChrpathPatchRule

Method AddChrpathPatchRule

Source/cmInstallTargetGenerator.cxx:725–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725void cmInstallTargetGenerator::AddChrpathPatchRule(
726 std::ostream& os, Indent indent, std::string const& config,
727 std::string const& toDestDirPath)
728{
729 // Skip the chrpath if the target does not need it.
730 if (this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly ||
731 !this->Target->IsChrpathUsed(config)) {
732 return;
733 }
734
735 // Get the link information for this target.
736 // It can provide the RPATH.
737 cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
738 if (!cli) {
739 return;
740 }
741
742 cmMakefile* mf = this->Target->Target->GetMakefile();
743
744 if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
745 // If using install_name_tool, set up the rules to modify the rpaths.
746 std::string installNameTool =
747 mf->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
748
749 std::vector<std::string> oldRuntimeDirs;
750 std::vector<std::string> newRuntimeDirs;
751 cli->GetRPath(oldRuntimeDirs, false);
752 cli->GetRPath(newRuntimeDirs, true);
753
754 std::string darwin_major_version_s =
755 mf->GetSafeDefinition("DARWIN_MAJOR_VERSION");
756
757 std::istringstream ss(darwin_major_version_s);
758 int darwin_major_version;
759 ss >> darwin_major_version;
760 if (!ss.fail() && darwin_major_version <= 9 &&
761 (!oldRuntimeDirs.empty() || !newRuntimeDirs.empty())) {
762 std::ostringstream msg;
763 msg
764 << "WARNING: Target \"" << this->Target->GetName()
765 << "\" has runtime paths which cannot be changed during install. "
766 << "To change runtime paths, OS X version 10.6 or newer is required. "
767 << "Therefore, runtime paths will not be changed when installing. "
768 << "CMAKE_BUILD_WITH_INSTALL_RPATH may be used to work around"
769 " this limitation.";
770 mf->IssueMessage(MessageType::WARNING, msg.str());
771 } else {
772 // To be consistent with older versions, runpath changes must be ordered,
773 // deleted first, then added, *and* the same path must only appear once.
774 std::map<std::string, std::string> runpath_change;
775 std::vector<std::string> ordered;
776 for (std::string const& dir : oldRuntimeDirs) {
777 // Normalize path and add to map of changes to make
778 auto iter_inserted = runpath_change.insert(
779 { mf->GetGlobalGenerator()->ExpandCFGIntDir(dir, config),
780 "delete" });
781 if (iter_inserted.second) {
782 // Add path to ordered list of changes

Callers 1

PostReplacementTweaksMethod · 0.95

Calls 15

IssueCMP0095WarningMethod · 0.95
IsChrpathUsedMethod · 0.80
GetLinkInformationMethod · 0.80
strMethod · 0.80
push_backMethod · 0.80
eraseMethod · 0.80
GetRPathStringMethod · 0.80
GetChrpathStringMethod · 0.80
GetMakefileMethod · 0.45
IsOnMethod · 0.45
GetRPathMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected