cmGeneratorTarget: Move IsChrPathUsed from cmTarget.
This commit is contained in:
parent
8d2de00244
commit
e27d737e27
@ -321,7 +321,11 @@ cmComputeLinkInformation
|
|||||||
this->RuntimeAlways =
|
this->RuntimeAlways =
|
||||||
(this->Makefile->
|
(this->Makefile->
|
||||||
GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
|
GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
|
||||||
this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config);
|
|
||||||
|
cmGeneratorTarget *gtgt = this->Target->GetMakefile()
|
||||||
|
->GetGlobalGenerator()
|
||||||
|
->GetGeneratorTarget(this->Target);
|
||||||
|
this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config);
|
||||||
|
|
||||||
// Get options needed to help find dependent libraries.
|
// Get options needed to help find dependent libraries.
|
||||||
std::string rlVar = "CMAKE_";
|
std::string rlVar = "CMAKE_";
|
||||||
|
@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If chrpath is going to be used no relinking is needed.
|
// If chrpath is going to be used no relinking is needed.
|
||||||
if(this->Target->IsChrpathUsed(config))
|
if(this->IsChrpathUsed(config))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const
|
|||||||
|| this->Target->HaveInstallTreeRPATH();
|
|| this->Target->HaveInstallTreeRPATH();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
|
||||||
|
{
|
||||||
|
// Only certain target types have an rpath.
|
||||||
|
if(!(this->GetType() == cmTarget::SHARED_LIBRARY ||
|
||||||
|
this->GetType() == cmTarget::MODULE_LIBRARY ||
|
||||||
|
this->GetType() == cmTarget::EXECUTABLE))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the target will not be installed we do not need to change its
|
||||||
|
// rpath.
|
||||||
|
if(!this->Target->GetHaveInstallRule())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip chrpath if skipping rpath altogether.
|
||||||
|
if(this->Makefile->IsOn("CMAKE_SKIP_RPATH"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip chrpath if it does not need to be changed at install time.
|
||||||
|
if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow the user to disable builtin chrpath explicitly.
|
||||||
|
if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CMAKE_USE_ELF_PARSER)
|
||||||
|
// Enable if the rpath flag uses a separator and the target uses ELF
|
||||||
|
// binaries.
|
||||||
|
std::string ll = this->Target->GetLinkerLanguage(config);
|
||||||
|
if(!ll.empty())
|
||||||
|
{
|
||||||
|
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||||
|
sepVar += ll;
|
||||||
|
sepVar += "_FLAG_SEP";
|
||||||
|
const char* sep = this->Makefile->GetDefinition(sepVar);
|
||||||
|
if(sep && *sep)
|
||||||
|
{
|
||||||
|
// TODO: Add ELF check to ABI detection and get rid of
|
||||||
|
// CMAKE_EXECUTABLE_FORMAT.
|
||||||
|
if(const char* fmt =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT"))
|
||||||
|
{
|
||||||
|
return strcmp(fmt, "ELF") == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
static_cast<void>(config);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
|
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
|
||||||
|
@ -215,6 +215,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool NeedRelinkBeforeInstall(const std::string& config) const;
|
bool NeedRelinkBeforeInstall(const std::string& config) const;
|
||||||
|
|
||||||
|
/** Return true if builtin chrpath will work for this target */
|
||||||
|
bool IsChrpathUsed(const std::string& config) const;
|
||||||
|
|
||||||
struct SourceFileFlags
|
struct SourceFileFlags
|
||||||
GetTargetSourceFileFlags(const cmSourceFile* sf) const;
|
GetTargetSourceFileFlags(const cmSourceFile* sf) const;
|
||||||
|
|
||||||
|
@ -656,11 +656,10 @@ cmInstallTargetGenerator
|
|||||||
std::string const& toDestDirPath)
|
std::string const& toDestDirPath)
|
||||||
{
|
{
|
||||||
// Skip the chrpath if the target does not need it.
|
// Skip the chrpath if the target does not need it.
|
||||||
if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config))
|
if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if on Apple
|
// Skip if on Apple
|
||||||
if(this->Target->Target->GetMakefile()
|
if(this->Target->Target->GetMakefile()
|
||||||
->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
|
->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
|
||||||
@ -695,7 +694,7 @@ cmInstallTargetGenerator
|
|||||||
std::string const& toDestDirPath)
|
std::string const& toDestDirPath)
|
||||||
{
|
{
|
||||||
// Skip the chrpath if the target does not need it.
|
// Skip the chrpath if the target does not need it.
|
||||||
if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config))
|
if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4313,73 +4313,6 @@ void cmTarget::GetLanguages(std::set<std::string>& languages,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool cmTarget::IsChrpathUsed(const std::string& config) const
|
|
||||||
{
|
|
||||||
// Only certain target types have an rpath.
|
|
||||||
if(!(this->GetType() == cmTarget::SHARED_LIBRARY ||
|
|
||||||
this->GetType() == cmTarget::MODULE_LIBRARY ||
|
|
||||||
this->GetType() == cmTarget::EXECUTABLE))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the target will not be installed we do not need to change its
|
|
||||||
// rpath.
|
|
||||||
if(!this->GetHaveInstallRule())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip chrpath if skipping rpath altogether.
|
|
||||||
if(this->Makefile->IsOn("CMAKE_SKIP_RPATH"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip chrpath if it does not need to be changed at install time.
|
|
||||||
if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow the user to disable builtin chrpath explicitly.
|
|
||||||
if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CMAKE_USE_ELF_PARSER)
|
|
||||||
// Enable if the rpath flag uses a separator and the target uses ELF
|
|
||||||
// binaries.
|
|
||||||
std::string ll = this->GetLinkerLanguage(config);
|
|
||||||
if(!ll.empty())
|
|
||||||
{
|
|
||||||
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
|
||||||
sepVar += ll;
|
|
||||||
sepVar += "_FLAG_SEP";
|
|
||||||
const char* sep = this->Makefile->GetDefinition(sepVar);
|
|
||||||
if(sep && *sep)
|
|
||||||
{
|
|
||||||
// TODO: Add ELF check to ABI detection and get rid of
|
|
||||||
// CMAKE_EXECUTABLE_FORMAT.
|
|
||||||
if(const char* fmt =
|
|
||||||
this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT"))
|
|
||||||
{
|
|
||||||
return strcmp(fmt, "ELF") == 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
static_cast<void>(config);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTarget::ImportInfo const*
|
cmTarget::ImportInfo const*
|
||||||
cmTarget::GetImportInfo(const std::string& config) const
|
cmTarget::GetImportInfo(const std::string& config) const
|
||||||
|
@ -398,9 +398,6 @@ public:
|
|||||||
bool HaveBuildTreeRPATH(const std::string& config) const;
|
bool HaveBuildTreeRPATH(const std::string& config) const;
|
||||||
bool HaveInstallTreeRPATH() const;
|
bool HaveInstallTreeRPATH() const;
|
||||||
|
|
||||||
/** Return true if builtin chrpath will work for this target */
|
|
||||||
bool IsChrpathUsed(const std::string& config) const;
|
|
||||||
|
|
||||||
/** Return the install name directory for the target in the
|
/** Return the install name directory for the target in the
|
||||||
* build tree. For example: "\@rpath/", "\@loader_path/",
|
* build tree. For example: "\@rpath/", "\@loader_path/",
|
||||||
* or "/full/path/to/library". */
|
* or "/full/path/to/library". */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user