cmInstallCommand: Store only a targetName, not a cmTarget.

Compute the cmTarget at Compute() time.
This commit is contained in:
Stephen Kelly 2015-07-28 19:32:03 +02:00
parent e5e5297018
commit 4e41913f9a
4 changed files with 28 additions and 11 deletions

View File

@ -27,7 +27,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target,
{
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
return new cmInstallTargetGenerator(target, args.GetDestination().c_str(),
return new cmInstallTargetGenerator(target.GetName(),
args.GetDestination().c_str(),
impLib, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(),
message,

View File

@ -22,13 +22,16 @@
//----------------------------------------------------------------------------
cmInstallTargetGenerator
::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib,
::cmInstallTargetGenerator(const std::string& targetName,
const char* dest, bool implib,
const char* file_permissions,
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
bool optional):
cmInstallGenerator(dest, configurations, component, message), Target(&t),
cmInstallGenerator(dest, configurations, component, message),
TargetName(targetName),
Target(0),
FilePermissions(file_permissions),
ImportLibrary(implib),
Optional(optional)
@ -430,6 +433,11 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
return fname;
}
void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
{
this->Target = lg->GetMakefile()->FindTarget(this->TargetName);
}
//----------------------------------------------------------------------------
void
cmInstallTargetGenerator

View File

@ -22,7 +22,7 @@ class cmInstallTargetGenerator: public cmInstallGenerator
{
public:
cmInstallTargetGenerator(
cmTarget& t, const char* dest, bool implib,
std::string const& targetName, const char* dest, bool implib,
const char* file_permissions,
std::vector<std::string> const& configurations,
const char* component,
@ -56,7 +56,10 @@ public:
const std::string& config,
NameType nameType = NameNormal);
void Compute(cmLocalGenerator* lg);
cmTarget* GetTarget() const { return this->Target; }
bool IsImportLibrary() const { return this->ImportLibrary; }
std::string GetDestination(std::string const& config) const;
@ -98,6 +101,7 @@ protected:
void AddRanlibRule(std::ostream& os, Indent const& indent,
const std::string& toDestDirPath);
std::string TargetName;
cmTarget* Target;
std::string FilePermissions;
NamelinkModeType NamelinkMode;

View File

@ -2375,11 +2375,15 @@ cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,
class cmInstallTargetGeneratorLocal: public cmInstallTargetGenerator
{
public:
cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib):
cmInstallTargetGeneratorLocal(cmLocalGenerator* lg, std::string const& t,
const char* dest, bool implib):
cmInstallTargetGenerator(
t, dest, implib, "", std::vector<std::string>(), "Unspecified",
cmInstallGenerator::SelectMessageLevel(t.GetMakefile()),
false) {}
cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()),
false)
{
this->Compute(lg);
}
};
//----------------------------------------------------------------------------
@ -2428,7 +2432,7 @@ cmLocalGenerator
{
// Use a target install generator.
cmInstallTargetGeneratorLocal
g(l->second, destination.c_str(), false);
g(this, l->first, destination.c_str(), false);
g.Generate(os, config, configurationTypes);
}
break;
@ -2439,18 +2443,18 @@ cmLocalGenerator
// to the normal destination and the DLL to the runtime
// destination.
cmInstallTargetGeneratorLocal
g1(l->second, destination.c_str(), true);
g1(this, l->first, destination.c_str(), true);
g1.Generate(os, config, configurationTypes);
// We also skip over the leading slash given by the user.
destination = l->second.GetRuntimeInstallPath().substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
cmInstallTargetGeneratorLocal
g2(l->second, destination.c_str(), false);
g2(this, l->first, destination.c_str(), false);
g2.Generate(os, config, configurationTypes);
#else
// Use a target install generator.
cmInstallTargetGeneratorLocal
g(l->second, destination.c_str(), false);
g(this, l->first, destination.c_str(), false);
g.Generate(os, config, configurationTypes);
#endif
}