summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2013-12-19 04:25:29 (GMT)
committerBrad King <brad.king@kitware.com>2014-01-02 18:41:49 (GMT)
commitd25ad482e978cbf5e4fcfa8b1dcc342ba93dcda0 (patch)
treef0a1f688356d4f346279bacc9203c467a5bb76ac /Source/cmTarget.cxx
parent2a384e08cc0809fec75ebb20be585fb5a1bf591a (diff)
downloadCMake-d25ad482e978cbf5e4fcfa8b1dcc342ba93dcda0.zip
CMake-d25ad482e978cbf5e4fcfa8b1dcc342ba93dcda0.tar.gz
CMake-d25ad482e978cbf5e4fcfa8b1dcc342ba93dcda0.tar.bz2
OS X: Add CMP0042 to enable MACOSX_RPATH by default
Also adding documentation for CMAKE_MACOSX_RPATH, and improving documentation for MACOSX_RPATH.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx53
1 files changed, 48 insertions, 5 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 38fe945..9ea7f07 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3185,13 +3185,17 @@ std::string cmTarget::GetSOName(const char* config) const
}
//----------------------------------------------------------------------------
-bool cmTarget::HasMacOSXRpath(const char* config) const
+bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const
{
bool install_name_is_rpath = false;
- bool macosx_rpath = this->GetPropertyAsBool("MACOSX_RPATH");
+ bool macosx_rpath = false;
if(!this->IsImportedTarget)
{
+ if(this->GetType() != cmTarget::SHARED_LIBRARY)
+ {
+ return false;
+ }
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
bool use_install_name =
this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
@@ -3204,6 +3208,10 @@ bool cmTarget::HasMacOSXRpath(const char* config) const
{
return false;
}
+ if(!install_name_is_rpath)
+ {
+ macosx_rpath = this->MacOSXRpathInstallNameDirDefault();
+ }
}
else
{
@@ -3258,6 +3266,37 @@ bool cmTarget::HasMacOSXRpath(const char* config) const
}
//----------------------------------------------------------------------------
+bool cmTarget::MacOSXRpathInstallNameDirDefault() const
+{
+ // we can't do rpaths when unsupported
+ if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
+ {
+ return false;
+ }
+
+ const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
+ if(macosx_rpath_str)
+ {
+ return this->GetPropertyAsBool("MACOSX_RPATH");
+ }
+
+ cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042();
+
+ if(cmp0042 == cmPolicies::WARN)
+ {
+ this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
+ AddCMP0042WarnTarget(this->GetName());
+ }
+
+ if(cmp0042 == cmPolicies::NEW)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+//----------------------------------------------------------------------------
bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const
{
if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY)
@@ -3846,7 +3885,8 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const
!this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
{
std::string dir;
- if(this->GetPropertyAsBool("MACOSX_RPATH"))
+ bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault();
+ if(macosx_rpath)
{
dir = "@rpath";
}
@@ -3880,9 +3920,12 @@ std::string cmTarget::GetInstallNameDirForInstallTree() const
dir += "/";
}
}
- if(!install_name_dir && this->GetPropertyAsBool("MACOSX_RPATH"))
+ if(!install_name_dir)
{
- dir = "@rpath/";
+ if(this->MacOSXRpathInstallNameDirDefault())
+ {
+ dir = "@rpath/";
+ }
}
return dir;
}