ENH: When linking to versioned targets whose real file name is known pass the real name to the linker instead of the symlink name.
This commit is contained in:
parent
a752fc5e85
commit
07be6bb87b
|
@ -514,7 +514,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt)
|
|||
// platform. Add it now.
|
||||
std::string linkItem;
|
||||
linkItem = this->LoaderFlag;
|
||||
std::string exe = tgt->GetFullPath(config, this->UseImportLibrary);
|
||||
std::string exe = tgt->GetFullPath(config, this->UseImportLibrary,
|
||||
true);
|
||||
linkItem += exe;
|
||||
this->Items.push_back(Item(linkItem, true));
|
||||
this->Depends.push_back(exe);
|
||||
|
@ -527,7 +528,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt)
|
|||
(impexe || tgt->GetType() == cmTarget::SHARED_LIBRARY));
|
||||
|
||||
// Pass the full path to the target file.
|
||||
std::string lib = tgt->GetFullPath(config, implib);
|
||||
std::string lib = tgt->GetFullPath(config, implib, true);
|
||||
this->Depends.push_back(lib);
|
||||
|
||||
if(tgt->IsFrameworkOnApple())
|
||||
|
@ -1254,14 +1255,13 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
|
|||
std::string soName = target->GetSOName(this->Config);
|
||||
const char* soname = soName.empty()? 0 : soName.c_str();
|
||||
|
||||
// Add the library runtime entry.
|
||||
this->AddLibraryRuntimeInfo(fullPath, soname);
|
||||
// Include this library in the runtime path ordering.
|
||||
this->OrderRuntimeSearchPath->AddLibrary(fullPath, soname);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
|
||||
const char* soname)
|
||||
cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath)
|
||||
{
|
||||
// Get the name of the library from the file name.
|
||||
std::string file = cmSystemTools::GetFilenameName(fullPath);
|
||||
|
@ -1284,7 +1284,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
|
|||
}
|
||||
|
||||
// Include this library in the runtime path ordering.
|
||||
this->OrderRuntimeSearchPath->AddLibrary(fullPath, soname);
|
||||
this->OrderRuntimeSearchPath->AddLibrary(fullPath);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -162,8 +162,7 @@ private:
|
|||
// Runtime path computation.
|
||||
cmOrderRuntimeDirectories* OrderRuntimeSearchPath;
|
||||
void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target);
|
||||
void AddLibraryRuntimeInfo(std::string const& fullPath,
|
||||
const char* soname = 0);
|
||||
void AddLibraryRuntimeInfo(std::string const& fullPath);
|
||||
|
||||
// Dependent library path computation.
|
||||
cmOrderRuntimeDirectories* OrderDependentRPath;
|
||||
|
|
|
@ -2007,6 +2007,40 @@ std::string cmTarget::GetSOName(const char* config)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmTarget::NormalGetRealName(const char* config)
|
||||
{
|
||||
// This should not be called for imported targets.
|
||||
// TODO: Split cmTarget into a class hierarchy to get compile-time
|
||||
// enforcement of the limited imported target API.
|
||||
if(this->IsImported())
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
if(this->GetType() == cmTarget::EXECUTABLE)
|
||||
{
|
||||
// Compute the real name that will be built.
|
||||
std::string name;
|
||||
std::string realName;
|
||||
std::string impName;
|
||||
std::string pdbName;
|
||||
this->GetExecutableNames(name, realName, impName, pdbName, config);
|
||||
return realName;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute the real name that will be built.
|
||||
std::string name;
|
||||
std::string soName;
|
||||
std::string realName;
|
||||
std::string impName;
|
||||
std::string pdbName;
|
||||
this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
|
||||
return realName;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmTarget::GetFullName(const char* config, bool implib)
|
||||
{
|
||||
|
@ -2037,7 +2071,8 @@ void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmTarget::GetFullPath(const char* config, bool implib)
|
||||
std::string cmTarget::GetFullPath(const char* config, bool implib,
|
||||
bool realname)
|
||||
{
|
||||
if(this->IsImported())
|
||||
{
|
||||
|
@ -2045,19 +2080,27 @@ std::string cmTarget::GetFullPath(const char* config, bool implib)
|
|||
}
|
||||
else
|
||||
{
|
||||
return this->NormalGetFullPath(config, implib);
|
||||
return this->NormalGetFullPath(config, implib, realname);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmTarget::NormalGetFullPath(const char* config, bool implib)
|
||||
std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
|
||||
bool realname)
|
||||
{
|
||||
// Start with the output directory for the target.
|
||||
std::string fpath = this->GetDirectory(config, implib);
|
||||
fpath += "/";
|
||||
|
||||
// Add the full name of the target.
|
||||
if(realname)
|
||||
{
|
||||
fpath += this->NormalGetRealName(config);
|
||||
}
|
||||
else
|
||||
{
|
||||
fpath += this->GetFullName(config, implib);
|
||||
}
|
||||
return fpath;
|
||||
}
|
||||
|
||||
|
|
|
@ -260,7 +260,8 @@ public:
|
|||
|
||||
/** Get the full path to the target according to the settings in its
|
||||
makefile and the configuration type. */
|
||||
std::string GetFullPath(const char* config=0, bool implib = false);
|
||||
std::string GetFullPath(const char* config=0, bool implib = false,
|
||||
bool realname = false);
|
||||
|
||||
/** Get the names of the library needed to generate a build rule
|
||||
that takes into account shared library version numbers. This
|
||||
|
@ -437,7 +438,14 @@ private:
|
|||
const char* NormalGetDirectory(const char* config, bool implib);
|
||||
|
||||
std::string ImportedGetFullPath(const char* config, bool implib);
|
||||
std::string NormalGetFullPath(const char* config, bool implib);
|
||||
std::string NormalGetFullPath(const char* config, bool implib,
|
||||
bool realname);
|
||||
|
||||
/** Get the real name of the target. Allowed only for non-imported
|
||||
targets. When a library or executable file is versioned this is
|
||||
the full versioned name. If the target is not versioned this is
|
||||
the same as GetFullName. */
|
||||
std::string NormalGetRealName(const char* config);
|
||||
|
||||
private:
|
||||
std::string Name;
|
||||
|
|
Loading…
Reference in New Issue