Commit a23fcc95 authored by Stephen Kelly's avatar Stephen Kelly

cmInstallTargetGenerator: Port to cmGeneratorTarget.

parent 4e41913f
......@@ -398,7 +398,7 @@ cmExportInstallFileGenerator
}
// Get the target to be installed.
cmTarget* target = itgen->GetTarget();
cmTarget* target = itgen->GetTarget()->Target;
// Construct the installed location of the target.
std::string dest = itgen->GetDestination(config);
......
......@@ -16,6 +16,7 @@
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmGeneratorTarget.h"
#include "cmake.h"
#include <assert.h>
......@@ -71,15 +72,17 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
{
// Compute the build tree directory from which to copy the target.
std::string fromDirConfig;
if(this->Target->NeedRelinkBeforeInstall(config))
if(this->Target->Target->NeedRelinkBeforeInstall(config))
{
fromDirConfig = this->Target->GetMakefile()->GetCurrentBinaryDirectory();
fromDirConfig =
this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory();
fromDirConfig += cmake::GetCMakeFilesDirectory();
fromDirConfig += "/CMakeRelink.dir/";
}
else
{
fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary);
fromDirConfig =
this->Target->Target->GetDirectory(config, this->ImportLibrary);
fromDirConfig += "/";
}
std::string toDir =
......@@ -90,7 +93,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::vector<std::string> filesFrom;
std::vector<std::string> filesTo;
std::string literal_args;
cmTarget::TargetType targetType = this->Target->GetType();
cmTarget::TargetType targetType =
static_cast<cmTarget::TargetType>(this->Target->GetType());
cmInstallType type = cmInstallType();
switch(targetType)
{
......@@ -107,7 +111,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
case cmTarget::UTILITY:
case cmTarget::GLOBAL_TARGET:
case cmTarget::UNKNOWN_LIBRARY:
this->Target->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR,
this->Target->Target->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR,
"cmInstallTargetGenerator created with non-installable target.");
return;
}
......@@ -120,7 +124,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::string targetNameReal;
std::string targetNameImport;
std::string targetNamePDB;
this->Target->GetExecutableNames(targetName, targetNameReal,
this->Target->Target->GetExecutableNames(targetName, targetNameReal,
targetNameImport, targetNamePDB,
config);
if(this->ImportLibrary)
......@@ -130,7 +134,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
filesFrom.push_back(from1);
filesTo.push_back(to1);
std::string targetNameImportLib;
if(this->Target->GetImplibGNUtoMS(targetNameImport,
if(this->Target->Target->GetImplibGNUtoMS(targetNameImport,
targetNameImportLib))
{
filesFrom.push_back(fromDirConfig + targetNameImportLib);
......@@ -146,7 +150,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::string to1 = toDir + targetName;
// Handle OSX Bundles.
if(this->Target->IsAppBundleOnApple())
if(this->Target->Target->IsAppBundleOnApple())
{
// Install the whole app bundle directory.
type = cmInstallType_DIRECTORY;
......@@ -180,7 +184,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::string targetNameReal;
std::string targetNameImport;
std::string targetNamePDB;
this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
this->Target->Target->GetLibraryNames(targetName, targetNameSO,
targetNameReal,
targetNameImport, targetNamePDB,
config);
if(this->ImportLibrary)
......@@ -193,7 +198,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
filesFrom.push_back(from1);
filesTo.push_back(to1);
std::string targetNameImportLib;
if(this->Target->GetImplibGNUtoMS(targetNameImport,
if(this->Target->Target->GetImplibGNUtoMS(targetNameImport,
targetNameImportLib))
{
filesFrom.push_back(fromDirConfig + targetNameImportLib);
......@@ -203,7 +208,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
// An import library looks like a static library.
type = cmInstallType_STATIC_LIBRARY;
}
else if(this->Target->IsFrameworkOnApple())
else if(this->Target->Target->IsFrameworkOnApple())
{
// There is a bug in cmInstallCommand if this fails.
assert(this->NamelinkMode == NamelinkModeNone);
......@@ -221,7 +226,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
filesFrom.push_back(from1);
filesTo.push_back(to1);
}
else if(this->Target->IsCFBundleOnApple())
else if(this->Target->Target->IsCFBundleOnApple())
{
// Install the whole app bundle directory.
type = cmInstallType_DIRECTORY;
......@@ -345,7 +350,7 @@ cmInstallTargetGenerator::GetDestination(std::string const& config) const
{
cmGeneratorExpression ge;
return ge.Parse(this->Destination)
->Evaluate(this->Target->GetMakefile(), config);
->Evaluate(this->Target->Target->GetMakefile(), config);
}
//----------------------------------------------------------------------------
......@@ -354,7 +359,7 @@ cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const
{
NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
return
cmInstallTargetGenerator::GetInstallFilename(this->Target, config,
cmInstallTargetGenerator::GetInstallFilename(this->Target->Target, config,
nameType);
}
......@@ -435,7 +440,8 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
{
this->Target = lg->GetMakefile()->FindTarget(this->TargetName);
this->Target = lg->GetGlobalGenerator()->GetGeneratorTarget(
lg->GetMakefile()->FindTarget(this->TargetName));
}
//----------------------------------------------------------------------------
......@@ -540,8 +546,8 @@ cmInstallTargetGenerator
}
// Fix the install_name settings in installed binaries.
std::string installNameTool =
this->Target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
std::string installNameTool = this->Target->Target->GetMakefile()
->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
if(installNameTool.empty())
{
......@@ -551,7 +557,8 @@ cmInstallTargetGenerator
// Build a map of build-tree install_name to install-tree install_name for
// shared libraries linked to this target.
std::map<std::string, std::string> install_name_remap;
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
if(cmComputeLinkInformation* cli =
this->Target->Target->GetLinkInformation(config))
{
std::set<cmTarget const*> const& sharedLibs
= cli->GetSharedLibrariesLinked();
......@@ -595,11 +602,11 @@ cmInstallTargetGenerator
if(this->Target->GetType() == cmTarget::SHARED_LIBRARY)
{
std::string for_build =
this->Target->GetInstallNameDirForBuildTree(config);
this->Target->Target->GetInstallNameDirForBuildTree(config);
std::string for_install =
this->Target->GetInstallNameDirForInstallTree();
this->Target->Target->GetInstallNameDirForInstallTree();
if(this->Target->IsFrameworkOnApple() && for_install.empty())
if(this->Target->Target->IsFrameworkOnApple() && for_install.empty())
{
// Frameworks seem to have an id corresponding to their own full
// path.
......@@ -613,7 +620,7 @@ cmInstallTargetGenerator
{
// Prepare to refer to the install-tree install_name.
new_id = for_install;
new_id += this->GetInstallFilename(this->Target, config, NameSO);
new_id += this->GetInstallFilename(this->Target->Target, config, NameSO);
}
}
......@@ -646,20 +653,22 @@ cmInstallTargetGenerator
std::string const& toDestDirPath)
{
// Skip the chrpath if the target does not need it.
if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config))
{
return;
}
// Skip if on Apple
if(this->Target->GetMakefile()->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
if(this->Target->Target->GetMakefile()
->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
return;
}
// Get the link information for this target.
// It can provide the RPATH.
cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
cmComputeLinkInformation* cli =
this->Target->Target->GetLinkInformation(config);
if(!cli)
{
return;
......@@ -684,20 +693,21 @@ cmInstallTargetGenerator
std::string const& toDestDirPath)
{
// Skip the chrpath if the target does not need it.
if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config))
{
return;
}
// Get the link information for this target.
// It can provide the RPATH.
cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
cmComputeLinkInformation* cli =
this->Target->Target->GetLinkInformation(config);
if(!cli)
{
return;
}
cmMakefile* mf = this->Target->GetMakefile();
cmMakefile* mf = this->Target->Target->GetMakefile();
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
......@@ -809,20 +819,20 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os,
}
// Don't handle OSX Bundles.
if(this->Target->GetMakefile()->IsOn("APPLE") &&
this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
if(this->Target->Target->GetMakefile()->IsOn("APPLE") &&
this->Target->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
{
return;
}
if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
if(! this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
{
return;
}
os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n";
os << indent << " execute_process(COMMAND \""
<< this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
<< this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
<< "\" \"" << toDestDirPath << "\")\n";
os << indent << "endif()\n";
}
......@@ -841,13 +851,13 @@ cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
// Perform post-installation processing on the file depending
// on its type.
if(!this->Target->GetMakefile()->IsOn("APPLE"))
if(!this->Target->Target->GetMakefile()->IsOn("APPLE"))
{
return;
}
std::string ranlib =
this->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
if(ranlib.empty())
{
return;
......
......@@ -13,7 +13,9 @@
#define cmInstallTargetGenerator_h
#include "cmInstallGenerator.h"
#include "cmTarget.h"
class cmTarget;
class cmGeneratorTarget;
/** \class cmInstallTargetGenerator
* \brief Generate target installation rules.
......@@ -58,7 +60,7 @@ public:
void Compute(cmLocalGenerator* lg);
cmTarget* GetTarget() const { return this->Target; }
cmGeneratorTarget* GetTarget() const { return this->Target; }
bool IsImportLibrary() const { return this->ImportLibrary; }
......@@ -102,7 +104,7 @@ protected:
const std::string& toDestDirPath);
std::string TargetName;
cmTarget* Target;
cmGeneratorTarget* Target;
std::string FilePermissions;
NamelinkModeType NamelinkMode;
bool ImportLibrary;
......
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