summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2017-02-09 14:46:40 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2017-02-14 21:28:01 (GMT)
commit4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f (patch)
treeb6e695ded8384436153375f00ace070439b90790 /Source/cmGeneratorTarget.cxx
parent624fb9d7175ee011f8a86c8d7614be4806a53184 (diff)
downloadCMake-4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f.zip
CMake-4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f.tar.gz
CMake-4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f.tar.bz2
Apple: Refactor support for using INSTALL_NAME_DIR.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx59
1 files changed, 39 insertions, 20 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 6ce8140..5dd0261 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -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 += "/";