Apple: Refactor support for using INSTALL_NAME_DIR.
This commit is contained in:
parent
624fb9d717
commit
4bff2d14fd
@ -1321,8 +1321,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
|
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
|
||||||
bool use_install_name =
|
bool use_install_name = this->MacOSXUseInstallNameDir();
|
||||||
this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
|
|
||||||
if (install_name && use_install_name &&
|
if (install_name && use_install_name &&
|
||||||
std::string(install_name) == "@rpath") {
|
std::string(install_name) == "@rpath") {
|
||||||
install_name_is_rpath = true;
|
install_name_is_rpath = true;
|
||||||
@ -1395,6 +1394,26 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
|
|||||||
return cmp0042 == cmPolicies::NEW;
|
return cmp0042 == cmPolicies::NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
|
||||||
|
{
|
||||||
|
bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
|
||||||
|
|
||||||
|
return use_install_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmGeneratorTarget::CanGenerateInstallNameDir(
|
||||||
|
InstallNameType name_type) const
|
||||||
|
{
|
||||||
|
bool skip = this->Makefile->IsOn("CMAKE_SKIP_RPATH");
|
||||||
|
if (name_type == INSTALL_NAME_FOR_INSTALL) {
|
||||||
|
skip |= this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
|
||||||
|
} else {
|
||||||
|
skip |= this->GetPropertyAsBool("SKIP_BUILD_RPATH");
|
||||||
|
}
|
||||||
|
|
||||||
|
return !skip;
|
||||||
|
}
|
||||||
|
|
||||||
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
|
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
|
||||||
{
|
{
|
||||||
if (this->IsImported()) {
|
if (this->IsImported()) {
|
||||||
@ -1503,24 +1522,25 @@ std::string cmGeneratorTarget::GetFullName(const std::string& config,
|
|||||||
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
|
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
|
||||||
const std::string& config) const
|
const std::string& config) const
|
||||||
{
|
{
|
||||||
// If building directly for installation then the build tree install_name
|
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
||||||
// is the same as the install tree.
|
|
||||||
if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
|
|
||||||
return this->GetInstallNameDirForInstallTree();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the build tree directory for the target.
|
// If building directly for installation then the build tree install_name
|
||||||
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
|
// is the same as the install tree.
|
||||||
!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
|
if (this->MacOSXUseInstallNameDir()) {
|
||||||
!this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
|
return this->GetInstallNameDirForInstallTree();
|
||||||
std::string dir;
|
}
|
||||||
if (this->MacOSXRpathInstallNameDirDefault()) {
|
|
||||||
dir = "@rpath";
|
// Use the build tree directory for the target.
|
||||||
} else {
|
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_BUILD)) {
|
||||||
dir = this->GetDirectory(config);
|
std::string dir;
|
||||||
|
if (this->MacOSXRpathInstallNameDirDefault()) {
|
||||||
|
dir = "@rpath";
|
||||||
|
} else {
|
||||||
|
dir = this->GetDirectory(config);
|
||||||
|
}
|
||||||
|
dir += "/";
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
dir += "/";
|
|
||||||
return dir;
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -1531,8 +1551,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
|
|||||||
std::string dir;
|
std::string dir;
|
||||||
const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
|
const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
|
||||||
|
|
||||||
if (!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
|
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
|
||||||
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) {
|
|
||||||
if (install_name_dir && *install_name_dir) {
|
if (install_name_dir && *install_name_dir) {
|
||||||
dir = install_name_dir;
|
dir = install_name_dir;
|
||||||
dir += "/";
|
dir += "/";
|
||||||
|
@ -525,6 +525,16 @@ public:
|
|||||||
/** Whether this library defaults to \@rpath. */
|
/** Whether this library defaults to \@rpath. */
|
||||||
bool MacOSXRpathInstallNameDirDefault() const;
|
bool MacOSXRpathInstallNameDirDefault() const;
|
||||||
|
|
||||||
|
enum InstallNameType
|
||||||
|
{
|
||||||
|
INSTALL_NAME_FOR_BUILD,
|
||||||
|
INSTALL_NAME_FOR_INSTALL
|
||||||
|
};
|
||||||
|
/** Whether to use INSTALL_NAME_DIR. */
|
||||||
|
bool MacOSXUseInstallNameDir() const;
|
||||||
|
/** Whether to generate an install_name. */
|
||||||
|
bool CanGenerateInstallNameDir(InstallNameType t) const;
|
||||||
|
|
||||||
/** Test for special case of a third-party shared library that has
|
/** Test for special case of a third-party shared library that has
|
||||||
no soname at all. */
|
no soname at all. */
|
||||||
bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
|
bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user