Commit d560bfd2 authored by Stephen Kelly's avatar Stephen Kelly

cmGeneratorTarget: Move GetInstallNameDir* from cmTarget.

parent 89e2a080
......@@ -333,12 +333,12 @@ cmExportBuildFileGenerator
}
std::string
cmExportBuildFileGenerator::InstallNameDir(cmTarget* target,
cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target,
const std::string& config)
{
std::string install_name_dir;
cmMakefile* mf = target->GetMakefile();
cmMakefile* mf = target->Target->GetMakefile();
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
install_name_dir =
......
......@@ -71,7 +71,8 @@ protected:
cmGeneratorTarget* target,
ImportPropertyMap& properties);
std::string InstallNameDir(cmTarget* target, const std::string& config);
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
std::vector<std::string>
FindNamespaces(cmMakefile* mf, const std::string& name);
......
......@@ -893,7 +893,7 @@ cmExportFileGenerator
{
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
value = this->InstallNameDir(target->Target, config);
value = this->InstallNameDir(target, config);
}
prop = "IMPORTED_SONAME";
value += target->GetSOName(config);
......
......@@ -200,7 +200,7 @@ private:
virtual void ReplaceInstallPrefix(std::string &input);
virtual std::string InstallNameDir(cmTarget* target,
virtual std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config) = 0;
};
......
......@@ -546,12 +546,12 @@ cmExportInstallFileGenerator
}
std::string
cmExportInstallFileGenerator::InstallNameDir(cmTarget* target,
cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target,
const std::string&)
{
std::string install_name_dir;
cmMakefile* mf = target->GetMakefile();
cmMakefile* mf = target->Target->GetMakefile();
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
install_name_dir =
......
......@@ -83,7 +83,8 @@ protected:
std::set<std::string>& importedLocations
);
std::string InstallNameDir(cmTarget* target, const std::string& config);
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
cmInstallExportGenerator* IEGen;
......
......@@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target,
}
std::string
cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target,
cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target,
const std::string& config)
{
std::string install_name_dir;
cmMakefile* mf = target->GetMakefile();
cmMakefile* mf = target->Target->GetMakefile();
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
install_name_dir =
......
......@@ -45,7 +45,7 @@ protected:
ImportPropertyMap& properties,
std::set<cmTarget const*> &emitted);
std::string InstallNameDir(cmTarget* target,
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
private:
std::string FindTargets(const std::string& prop, cmTarget const* tgt,
......
......@@ -890,6 +890,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
}
}
//----------------------------------------------------------------------------
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();
}
// 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->Target->MacOSXRpathInstallNameDirDefault())
{
dir = "@rpath";
}
else
{
dir = this->Target->GetDirectory(config);
}
dir += "/";
return dir;
}
else
{
return "";
}
}
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
{
if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
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(install_name_dir && *install_name_dir)
{
dir = install_name_dir;
dir += "/";
}
}
if(!install_name_dir)
{
if(this->Target->MacOSXRpathInstallNameDirDefault())
{
dir = "@rpath/";
}
}
return dir;
}
else
{
return "";
}
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
std::string& base,
......
......@@ -115,6 +115,15 @@ public:
bool realname) const;
std::string NormalGetRealName(const std::string& config) const;
/** Return the install name directory for the target in the
* build tree. For example: "\@rpath/", "\@loader_path/",
* or "/full/path/to/library". */
std::string GetInstallNameDirForBuildTree(const std::string& config) const;
/** Return the install name directory for the target in the
* install tree. For example: "\@rpath/" or "\@loader_path/". */
std::string GetInstallNameDirForInstallTree() const;
/** Get the soname of the target. Allowed only for a shared library. */
std::string GetSOName(const std::string& config) const;
......
......@@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
if(target.GetType() == cmTarget::SHARED_LIBRARY)
{
// Get the install_name directory for the build tree.
install_name_dir = target.GetInstallNameDirForBuildTree(configName);
install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName);
// Xcode doesn't create the correct install_name in some cases.
// That is, if the INSTALL_PATH is empty, or if we have versioning
// of dylib libraries, we want to specify the install_name.
......
......@@ -576,11 +576,14 @@ cmInstallTargetGenerator
continue;
}
cmGeneratorTarget *gtgt = tgt->GetMakefile()
->GetGlobalGenerator()
->GetGeneratorTarget(tgt);
// If the build tree and install tree use different path
// components of the install_name field then we need to create a
// mapping to be applied after installation.
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
std::string for_install = tgt->GetInstallNameDirForInstallTree();
std::string for_build = gtgt->GetInstallNameDirForBuildTree(config);
std::string for_install = gtgt->GetInstallNameDirForInstallTree();
if(for_build != for_install)
{
// The directory portions differ. Append the filename to
......@@ -605,9 +608,9 @@ cmInstallTargetGenerator
if(this->Target->GetType() == cmTarget::SHARED_LIBRARY)
{
std::string for_build =
this->Target->Target->GetInstallNameDirForBuildTree(config);
this->Target->GetInstallNameDirForBuildTree(config);
std::string for_install =
this->Target->Target->GetInstallNameDirForInstallTree();
this->Target->GetInstallNameDirForInstallTree();
if(this->Target->Target->IsFrameworkOnApple() && for_install.empty())
{
......
......@@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
// Get the install_name directory for the build tree.
install_name_dir =
this->Target->GetInstallNameDirForBuildTree(this->ConfigName);
this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName);
// Set the rule variable replacement value.
if(install_name_dir.empty())
......
......@@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["SONAME"] = this->TargetNameSO;
if (targetType == cmTarget::SHARED_LIBRARY)
{
std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName);
std::string install_dir =
this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName);
if (!install_dir.empty())
{
vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir,
......
......@@ -3845,73 +3845,6 @@ bool cmTarget::HaveInstallTreeRPATH() const
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
}
//----------------------------------------------------------------------------
std::string cmTarget::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 GetInstallNameDirForInstallTree();
}
// 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;
bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault();
if(macosx_rpath)
{
dir = "@rpath";
}
else
{
dir = this->GetDirectory(config);
}
dir += "/";
return dir;
}
else
{
return "";
}
}
//----------------------------------------------------------------------------
std::string cmTarget::GetInstallNameDirForInstallTree() const
{
if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
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(install_name_dir && *install_name_dir)
{
dir = install_name_dir;
dir += "/";
}
}
if(!install_name_dir)
{
if(this->MacOSXRpathInstallNameDirDefault())
{
dir = "@rpath/";
}
}
return dir;
}
else
{
return "";
}
}
//----------------------------------------------------------------------------
const char* cmTarget::GetOutputTargetType(bool implib) const
{
......
......@@ -394,15 +394,6 @@ public:
bool HaveBuildTreeRPATH(const std::string& config) const;
bool HaveInstallTreeRPATH() const;
/** Return the install name directory for the target in the
* build tree. For example: "\@rpath/", "\@loader_path/",
* or "/full/path/to/library". */
std::string GetInstallNameDirForBuildTree(const std::string& config) const;
/** Return the install name directory for the target in the
* install tree. For example: "\@rpath/" or "\@loader_path/". */
std::string GetInstallNameDirForInstallTree() const;
// Get the properties
cmPropertyMap &GetProperties() const { return this->Properties; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment