summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-08-05 17:07:03 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-10-10 09:03:48 (GMT)
commite73916992c6893572f24ee4fa631b33445d6cdf6 (patch)
treec569a4a8b11ad4dd716f14862e2e3990b9241613 /Source/cmGeneratorTarget.cxx
parentc5718217ad242ca0fc6e6b15f4ee670e4a332c93 (diff)
downloadCMake-e73916992c6893572f24ee4fa631b33445d6cdf6.zip
CMake-e73916992c6893572f24ee4fa631b33445d6cdf6.tar.gz
CMake-e73916992c6893572f24ee4fa631b33445d6cdf6.tar.bz2
cmGeneratorTarget: Move HasMacOSXRpathInstallNameDir from cmTarget.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx118
1 files changed, 116 insertions, 2 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 6ad6c69..b253836 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1284,6 +1284,120 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
//----------------------------------------------------------------------------
+bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
+ const std::string& config) const
+{
+ bool install_name_is_rpath = false;
+ bool macosx_rpath = false;
+
+ if(!this->IsImported())
+ {
+ 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");
+ if(install_name && use_install_name &&
+ std::string(install_name) == "@rpath")
+ {
+ install_name_is_rpath = true;
+ }
+ else if(install_name && use_install_name)
+ {
+ return false;
+ }
+ if(!install_name_is_rpath)
+ {
+ macosx_rpath = this->MacOSXRpathInstallNameDirDefault();
+ }
+ }
+ else
+ {
+ // Lookup the imported soname.
+ if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config))
+ {
+ if(!info->NoSOName && !info->SOName.empty())
+ {
+ if(info->SOName.find("@rpath/") == 0)
+ {
+ install_name_is_rpath = true;
+ }
+ }
+ else
+ {
+ std::string install_name;
+ cmSystemTools::GuessLibraryInstallName(info->Location, install_name);
+ if(install_name.find("@rpath") != std::string::npos)
+ {
+ install_name_is_rpath = true;
+ }
+ }
+ }
+ }
+
+ if(!install_name_is_rpath && !macosx_rpath)
+ {
+ return false;
+ }
+
+ if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
+ {
+ std::ostringstream w;
+ w << "Attempting to use";
+ if(macosx_rpath)
+ {
+ w << " MACOSX_RPATH";
+ }
+ else
+ {
+ w << " @rpath";
+ }
+ w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set.";
+ w << " This could be because you are using a Mac OS X version";
+ w << " less than 10.5 or because CMake's platform configuration is";
+ w << " corrupt.";
+ cmake* cm = this->Makefile->GetCMakeInstance();
+ cm->IssueMessage(cmake::FATAL_ERROR, w.str(),
+ this->Target->GetBacktrace());
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmGeneratorTarget::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->Target->GetPolicyStatusCMP0042();
+
+ if(cmp0042 == cmPolicies::WARN)
+ {
+ this->Makefile->GetGlobalGenerator()->
+ AddCMP0042WarnTarget(this->GetName());
+ }
+
+ if(cmp0042 == cmPolicies::NEW)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
{
if(this->Target->IsImported())
@@ -1428,7 +1542,7 @@ cmGeneratorTarget::GetInstallNameDirForBuildTree(
!this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
{
std::string dir;
- if(this->Target->MacOSXRpathInstallNameDirDefault())
+ if(this->MacOSXRpathInstallNameDirDefault())
{
dir = "@rpath";
}
@@ -1464,7 +1578,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
}
if(!install_name_dir)
{
- if(this->Target->MacOSXRpathInstallNameDirDefault())
+ if(this->MacOSXRpathInstallNameDirDefault())
{
dir = "@rpath/";
}