ENH: Update cmInstallTargetGenerator to get the shared libraries linked by a target from cmComputeLinkInformation instead of duplicating the computation.
This commit is contained in:
parent
6e70424fc8
commit
319c4c4d80
|
@ -283,6 +283,13 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
|
||||||
return this->FrameworkPaths;
|
return this->FrameworkPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
std::set<cmTarget*> const&
|
||||||
|
cmComputeLinkInformation::GetSharedLibrariesLinked()
|
||||||
|
{
|
||||||
|
return this->SharedLibrariesLinked;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmComputeLinkInformation::Compute()
|
bool cmComputeLinkInformation::Compute()
|
||||||
{
|
{
|
||||||
|
@ -340,6 +347,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep track of shared libraries linked.
|
||||||
|
if(tgt && tgt->GetType() == cmTarget::SHARED_LIBRARY)
|
||||||
|
{
|
||||||
|
this->SharedLibrariesLinked.insert(tgt);
|
||||||
|
}
|
||||||
|
|
||||||
if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY ||
|
if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY ||
|
||||||
tgt->GetType() == cmTarget::SHARED_LIBRARY ||
|
tgt->GetType() == cmTarget::SHARED_LIBRARY ||
|
||||||
tgt->GetType() == cmTarget::MODULE_LIBRARY ||
|
tgt->GetType() == cmTarget::MODULE_LIBRARY ||
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
std::string GetRPathString(bool for_install);
|
std::string GetRPathString(bool for_install);
|
||||||
std::string GetChrpathString();
|
std::string GetChrpathString();
|
||||||
std::string GetChrpathTool();
|
std::string GetChrpathTool();
|
||||||
|
std::set<cmTarget*> const& GetSharedLibrariesLinked();
|
||||||
private:
|
private:
|
||||||
void AddItem(std::string const& item, cmTarget* tgt);
|
void AddItem(std::string const& item, cmTarget* tgt);
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ private:
|
||||||
std::vector<std::string> Depends;
|
std::vector<std::string> Depends;
|
||||||
std::vector<std::string> FrameworkPaths;
|
std::vector<std::string> FrameworkPaths;
|
||||||
std::vector<std::string> RuntimeSearchPath;
|
std::vector<std::string> RuntimeSearchPath;
|
||||||
|
std::set<cmTarget*> SharedLibrariesLinked;
|
||||||
|
|
||||||
// Context information.
|
// Context information.
|
||||||
cmTarget* Target;
|
cmTarget* Target;
|
||||||
|
|
|
@ -382,56 +382,37 @@ cmInstallTargetGenerator
|
||||||
// Build a map of build-tree install_name to install-tree install_name for
|
// Build a map of build-tree install_name to install-tree install_name for
|
||||||
// shared libraries linked to this target.
|
// shared libraries linked to this target.
|
||||||
std::map<cmStdString, cmStdString> install_name_remap;
|
std::map<cmStdString, cmStdString> install_name_remap;
|
||||||
cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
|
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
|
||||||
if(config && cmSystemTools::UpperCase(config) == "DEBUG")
|
|
||||||
{
|
{
|
||||||
linkType = cmTarget::DEBUG;
|
std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked();
|
||||||
}
|
for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin();
|
||||||
// TODO: Merge with ComputeLinkInformation.
|
j != sharedLibs.end(); ++j)
|
||||||
const cmTarget::LinkLibraryVectorType& inLibs =
|
|
||||||
this->Target->GetLinkLibraries();
|
|
||||||
for(cmTarget::LinkLibraryVectorType::const_iterator j = inLibs.begin();
|
|
||||||
j != inLibs.end(); ++j)
|
|
||||||
{
|
|
||||||
std::string lib = j->first;
|
|
||||||
if((this->Target->GetType() == cmTarget::EXECUTABLE ||
|
|
||||||
lib != this->Target->GetName()) &&
|
|
||||||
(j->second == cmTarget::GENERAL || j->second == linkType))
|
|
||||||
{
|
{
|
||||||
if(cmTarget* tgt = this->Target->GetMakefile()->
|
// If the build tree and install tree use different path
|
||||||
GetLocalGenerator()->GetGlobalGenerator()->
|
// components of the install_name field then we need to create a
|
||||||
FindTarget(0, lib.c_str()))
|
// mapping to be applied after installation.
|
||||||
|
cmTarget* tgt = *j;
|
||||||
|
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
|
||||||
|
std::string for_install = tgt->GetInstallNameDirForInstallTree(config);
|
||||||
|
std::string fname = this->GetInstallFilename(tgt, config, false, true);
|
||||||
|
|
||||||
|
// Map from the build-tree install_name.
|
||||||
|
for_build += fname;
|
||||||
|
|
||||||
|
// Map to the install-tree install_name.
|
||||||
|
if (!for_install.empty())
|
||||||
{
|
{
|
||||||
if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
|
for_install += fname;
|
||||||
{
|
}
|
||||||
// If the build tree and install tree use different path
|
else
|
||||||
// components of the install_name field then we need to create a
|
{
|
||||||
// mapping to be applied after installation.
|
for_install = tgt->GetInstallNameFixupPath();
|
||||||
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
|
}
|
||||||
std::string for_install =
|
|
||||||
tgt->GetInstallNameDirForInstallTree(config);
|
|
||||||
std::string fname =
|
|
||||||
this->GetInstallFilename(tgt, config, false, true);
|
|
||||||
|
|
||||||
// Map from the build-tree install_name.
|
if(for_build != for_install)
|
||||||
for_build += fname;
|
{
|
||||||
|
// Store the mapping entry.
|
||||||
// Map to the install-tree install_name.
|
install_name_remap[for_build] = for_install;
|
||||||
if (!for_install.empty())
|
|
||||||
{
|
|
||||||
for_install += fname;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for_install = tgt->GetInstallNameFixupPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(for_build != for_install)
|
|
||||||
{
|
|
||||||
// Store the mapping entry.
|
|
||||||
install_name_remap[for_build] = for_install;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue