mirror of
https://github.com/reactos/CMake.git
synced 2024-12-04 09:54:15 +00:00
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;
|
||||
}
|
||||
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
|
||||
bool use_install_name =
|
||||
this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
|
||||
bool use_install_name = this->MacOSXUseInstallNameDir();
|
||||
if (install_name && use_install_name &&
|
||||
std::string(install_name) == "@rpath") {
|
||||
install_name_is_rpath = true;
|
||||
@ -1395,6 +1394,26 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
|
||||
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
|
||||
{
|
||||
if (this->IsImported()) {
|
||||
@ -1503,24 +1522,25 @@ std::string cmGeneratorTarget::GetFullName(const std::string& config,
|
||||
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
|
||||
const std::string& config) const
|
||||
{
|
||||
// If building directly for installation then the build tree install_name
|
||||
// is the same as the install tree.
|
||||
if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
|
||||
return this->GetInstallNameDirForInstallTree();
|
||||
}
|
||||
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
||||
|
||||
// Use the build tree directory for the target.
|
||||
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
|
||||
!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
|
||||
!this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
|
||||
std::string dir;
|
||||
if (this->MacOSXRpathInstallNameDirDefault()) {
|
||||
dir = "@rpath";
|
||||
} else {
|
||||
dir = this->GetDirectory(config);
|
||||
// If building directly for installation then the build tree install_name
|
||||
// is the same as the install tree.
|
||||
if (this->MacOSXUseInstallNameDir()) {
|
||||
return this->GetInstallNameDirForInstallTree();
|
||||
}
|
||||
|
||||
// Use the build tree directory for the target.
|
||||
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_BUILD)) {
|
||||
std::string dir;
|
||||
if (this->MacOSXRpathInstallNameDirDefault()) {
|
||||
dir = "@rpath";
|
||||
} else {
|
||||
dir = this->GetDirectory(config);
|
||||
}
|
||||
dir += "/";
|
||||
return dir;
|
||||
}
|
||||
dir += "/";
|
||||
return dir;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -1531,8 +1551,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
|
||||
std::string dir;
|
||||
const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
|
||||
|
||||
if (!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
|
||||
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) {
|
||||
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
|
||||
if (install_name_dir && *install_name_dir) {
|
||||
dir = install_name_dir;
|
||||
dir += "/";
|
||||
|
@ -525,6 +525,16 @@ public:
|
||||
/** Whether this library defaults to \@rpath. */
|
||||
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
|
||||
no soname at all. */
|
||||
bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
|
||||
|
Loading…
Reference in New Issue
Block a user