cmExportSet: Store a cmGeneratorTarget.

Set the member at compute time from the stored name.
This commit is contained in:
Stephen Kelly 2015-10-17 13:31:33 +02:00
parent 65911cae4d
commit 381e7afd36
8 changed files with 41 additions and 27 deletions

View File

@ -27,6 +27,10 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator()
void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg) void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg)
{ {
this->LG = lg; this->LG = lg;
if (this->ExportSet)
{
this->ExportSet->Compute(lg);
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -274,7 +278,7 @@ void cmExportBuildFileGenerator
tei = this->ExportSet->GetTargetExports()->begin(); tei = this->ExportSet->GetTargetExports()->begin();
tei != this->ExportSet->GetTargetExports()->end(); ++tei) tei != this->ExportSet->GetTargetExports()->end(); ++tei)
{ {
targets.push_back((*tei)->GetName()); targets.push_back((*tei)->TargetName);
} }
return; return;
} }

View File

@ -398,11 +398,11 @@ void cmExportFileGenerator::PopulateSourcesInterface(
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
{ {
cmTarget *target = tei->Target; cmGeneratorTarget* gt = tei->Target;
assert(preprocessRule == cmGeneratorExpression::InstallInterface); assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char *propName = "INTERFACE_SOURCES"; const char *propName = "INTERFACE_SOURCES";
const char *input = target->GetProperty(propName); const char *input = gt->GetProperty(propName);
if (!input) if (!input)
{ {
@ -420,11 +420,9 @@ void cmExportFileGenerator::PopulateSourcesInterface(
true); true);
if (!prepro.empty()) if (!prepro.empty())
{ {
this->ResolveTargetsInGeneratorExpressions(prepro, target, this->ResolveTargetsInGeneratorExpressions(prepro, gt->Target,
missingTargets); missingTargets);
cmGeneratorTarget* gt = target->GetMakefile()
->GetGlobalGenerator()->GetGeneratorTarget(target);
if (!checkInterfaceDirs(prepro, gt, propName)) if (!checkInterfaceDirs(prepro, gt, propName))
{ {
return; return;
@ -440,9 +438,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
{ {
cmGeneratorTarget *target = tei->Target->GetMakefile() cmGeneratorTarget *target = tei->Target;
->GetGlobalGenerator()
->GetGeneratorTarget(tei->Target);
assert(preprocessRule == cmGeneratorExpression::InstallInterface); assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";

View File

@ -48,10 +48,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
{ {
expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName(); expectedTargets +=
sep + this->Namespace + (*tei)->Target->Target->GetExportName();
sep = " "; sep = " ";
cmTargetExport * te = *tei; cmTargetExport * te = *tei;
if(this->ExportedTargets.insert(te->Target).second) if(this->ExportedTargets.insert(te->Target->Target).second)
{ {
allTargets.push_back(te); allTargets.push_back(te);
} }
@ -131,7 +132,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
tei = allTargets.begin(); tei = allTargets.begin();
tei != allTargets.end(); ++tei) tei != allTargets.end(); ++tei)
{ {
cmTarget* te = (*tei)->Target; cmGeneratorTarget* gt = (*tei)->Target;
cmTarget* te = gt->Target;
requiresConfigFiles = requiresConfigFiles requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmState::INTERFACE_LIBRARY; || te->GetType() != cmState::INTERFACE_LIBRARY;
@ -193,13 +195,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties); te, properties);
cmGeneratorTarget *gtgt = te->GetMakefile()
->GetGlobalGenerator()
->GetGeneratorTarget(te);
this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->PopulateCompatibleInterfaceProperties(gt, properties);
this->GenerateInterfaceProperties(te, os, properties); this->GenerateInterfaceProperties(gt->Target, os, properties);
} }
if (require3_1_0) if (require3_1_0)
@ -362,8 +361,7 @@ cmExportInstallFileGenerator
if(!properties.empty()) if(!properties.empty())
{ {
// Get the rest of the target details. // Get the rest of the target details.
cmGeneratorTarget *gtgt = te->Target->GetMakefile() cmGeneratorTarget *gtgt = te->Target;
->GetGlobalGenerator()->GetGeneratorTarget(te->Target);
this->SetImportDetailProperties(config, suffix, this->SetImportDetailProperties(config, suffix,
gtgt, properties, missingTargets); gtgt, properties, missingTargets);
@ -378,8 +376,8 @@ cmExportInstallFileGenerator
// properties); // properties);
// Generate code in the export file. // Generate code in the export file.
this->GenerateImportPropertyCode(os, config, te->Target, properties); this->GenerateImportPropertyCode(os, config, gtgt->Target, properties);
this->GenerateImportedFileChecksCode(os, te->Target, properties, this->GenerateImportedFileChecksCode(os, gtgt->Target, properties,
importedLocations); importedLocations);
} }
} }

View File

@ -13,12 +13,22 @@
#include "cmExportSet.h" #include "cmExportSet.h"
#include "cmTargetExport.h" #include "cmTargetExport.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmLocalGenerator.h"
cmExportSet::~cmExportSet() cmExportSet::~cmExportSet()
{ {
cmDeleteAll(this->TargetExports); cmDeleteAll(this->TargetExports);
} }
void cmExportSet::Compute(cmLocalGenerator* lg)
{
for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin();
it != this->TargetExports.end(); ++it)
{
(*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName);
}
}
void cmExportSet::AddTargetExport(cmTargetExport* te) void cmExportSet::AddTargetExport(cmTargetExport* te)
{ {
this->TargetExports.push_back(te); this->TargetExports.push_back(te);

View File

@ -15,6 +15,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
class cmTargetExport; class cmTargetExport;
class cmInstallExportGenerator; class cmInstallExportGenerator;
class cmLocalGenerator;
/// A set of targets that were installed with the same EXPORT parameter. /// A set of targets that were installed with the same EXPORT parameter.
class cmExportSet class cmExportSet
@ -25,6 +26,8 @@ public:
/// Destructor /// Destructor
~cmExportSet(); ~cmExportSet();
void Compute(cmLocalGenerator* lg);
void AddTargetExport(cmTargetExport* tgt); void AddTargetExport(cmTargetExport* tgt);
void AddInstallation(cmInstallExportGenerator const* installation); void AddInstallation(cmInstallExportGenerator const* installation);

View File

@ -773,7 +773,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if(!exports.GetString().empty() && !namelinkOnly) if(!exports.GetString().empty() && !namelinkOnly)
{ {
cmTargetExport *te = new cmTargetExport; cmTargetExport *te = new cmTargetExport;
te->Target = &target; te->TargetName = target.GetName();
te->ArchiveGenerator = archiveGenerator; te->ArchiveGenerator = archiveGenerator;
te->BundleGenerator = bundleGenerator; te->BundleGenerator = bundleGenerator;
te->FrameworkGenerator = frameworkGenerator; te->FrameworkGenerator = frameworkGenerator;
@ -1379,16 +1379,17 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
tei != exportSet->GetTargetExports()->end(); ++tei) tei != exportSet->GetTargetExports()->end(); ++tei)
{ {
cmTargetExport const* te = *tei; cmTargetExport const* te = *tei;
cmTarget* tgt = this->Makefile->FindTarget(te->TargetName);
const bool newCMP0022Behavior = const bool newCMP0022Behavior =
te->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& te->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if(!newCMP0022Behavior) if(!newCMP0022Behavior)
{ {
std::ostringstream e; std::ostringstream e;
e << "INSTALL(EXPORT) given keyword \"" e << "INSTALL(EXPORT) given keyword \""
<< "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \""
<< te->Target->GetName() << te->TargetName
<< "\" does not have policy CMP0022 set to NEW."; << "\" does not have policy CMP0022 set to NEW.";
this->SetError(e.str()); this->SetError(e.str());
return false; return false;

View File

@ -56,6 +56,7 @@ cmInstallExportGenerator::~cmInstallExportGenerator()
void cmInstallExportGenerator::Compute(cmLocalGenerator* lg) void cmInstallExportGenerator::Compute(cmLocalGenerator* lg)
{ {
this->LocalGenerator = lg; this->LocalGenerator = lg;
this->ExportSet->Compute(lg);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -14,7 +14,7 @@
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
class cmTarget; class cmGeneratorTarget;
class cmInstallTargetGenerator; class cmInstallTargetGenerator;
class cmInstallFilesGenerator; class cmInstallFilesGenerator;
@ -25,7 +25,8 @@ class cmInstallFilesGenerator;
class cmTargetExport class cmTargetExport
{ {
public: public:
cmTarget* Target; ///< The target std::string TargetName;
cmGeneratorTarget* Target;
///@name Generators ///@name Generators
///@{ ///@{