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