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::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(target.GetMakefile()); 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(), impLib, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(), args.GetConfigurations(), args.GetComponent().c_str(),
message, message,

View File

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

View File

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

View File

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