From 4e41913f9acb6a33f6a4eb1b88577fb7499e99d6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 19:32:03 +0200 Subject: [PATCH] cmInstallCommand: Store only a targetName, not a cmTarget. Compute the cmTarget at Compute() time. --- Source/cmInstallCommand.cxx | 3 ++- Source/cmInstallTargetGenerator.cxx | 12 ++++++++++-- Source/cmInstallTargetGenerator.h | 6 +++++- Source/cmLocalGenerator.cxx | 18 +++++++++++------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index a33acaddf..f548f5dd6 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -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, diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 09af56e0f..a5d8a74cd 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -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 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 diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index db69220a1..128e1a20d 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -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 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; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2e20ee28c..6b48a447c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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(), "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 }