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)
{
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()->end(); ++tei)
{
targets.push_back((*tei)->GetName());
targets.push_back((*tei)->TargetName);
}
return;
}

View File

@ -398,11 +398,11 @@ void cmExportFileGenerator::PopulateSourcesInterface(
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets)
{
cmTarget *target = tei->Target;
cmGeneratorTarget* gt = tei->Target;
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char *propName = "INTERFACE_SOURCES";
const char *input = target->GetProperty(propName);
const char *input = gt->GetProperty(propName);
if (!input)
{
@ -420,11 +420,9 @@ void cmExportFileGenerator::PopulateSourcesInterface(
true);
if (!prepro.empty())
{
this->ResolveTargetsInGeneratorExpressions(prepro, target,
this->ResolveTargetsInGeneratorExpressions(prepro, gt->Target,
missingTargets);
cmGeneratorTarget* gt = target->GetMakefile()
->GetGlobalGenerator()->GetGeneratorTarget(target);
if (!checkInterfaceDirs(prepro, gt, propName))
{
return;
@ -440,9 +438,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets)
{
cmGeneratorTarget *target = tei->Target->GetMakefile()
->GetGlobalGenerator()
->GetGeneratorTarget(tei->Target);
cmGeneratorTarget *target = tei->Target;
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
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()->end(); ++tei)
{
expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName();
expectedTargets +=
sep + this->Namespace + (*tei)->Target->Target->GetExportName();
sep = " ";
cmTargetExport * te = *tei;
if(this->ExportedTargets.insert(te->Target).second)
if(this->ExportedTargets.insert(te->Target->Target).second)
{
allTargets.push_back(te);
}
@ -131,7 +132,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
tei = allTargets.begin();
tei != allTargets.end(); ++tei)
{
cmTarget* te = (*tei)->Target;
cmGeneratorTarget* gt = (*tei)->Target;
cmTarget* te = gt->Target;
requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmState::INTERFACE_LIBRARY;
@ -193,13 +195,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
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)
@ -362,8 +361,7 @@ cmExportInstallFileGenerator
if(!properties.empty())
{
// Get the rest of the target details.
cmGeneratorTarget *gtgt = te->Target->GetMakefile()
->GetGlobalGenerator()->GetGeneratorTarget(te->Target);
cmGeneratorTarget *gtgt = te->Target;
this->SetImportDetailProperties(config, suffix,
gtgt, properties, missingTargets);
@ -378,8 +376,8 @@ cmExportInstallFileGenerator
// properties);
// Generate code in the export file.
this->GenerateImportPropertyCode(os, config, te->Target, properties);
this->GenerateImportedFileChecksCode(os, te->Target, properties,
this->GenerateImportPropertyCode(os, config, gtgt->Target, properties);
this->GenerateImportedFileChecksCode(os, gtgt->Target, properties,
importedLocations);
}
}

View File

@ -13,12 +13,22 @@
#include "cmExportSet.h"
#include "cmTargetExport.h"
#include "cmAlgorithms.h"
#include "cmLocalGenerator.h"
cmExportSet::~cmExportSet()
{
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)
{
this->TargetExports.push_back(te);

View File

@ -15,6 +15,7 @@
#include "cmSystemTools.h"
class cmTargetExport;
class cmInstallExportGenerator;
class cmLocalGenerator;
/// A set of targets that were installed with the same EXPORT parameter.
class cmExportSet
@ -25,6 +26,8 @@ public:
/// Destructor
~cmExportSet();
void Compute(cmLocalGenerator* lg);
void AddTargetExport(cmTargetExport* tgt);
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)
{
cmTargetExport *te = new cmTargetExport;
te->Target = &target;
te->TargetName = target.GetName();
te->ArchiveGenerator = archiveGenerator;
te->BundleGenerator = bundleGenerator;
te->FrameworkGenerator = frameworkGenerator;
@ -1379,16 +1379,17 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
tei != exportSet->GetTargetExports()->end(); ++tei)
{
cmTargetExport const* te = *tei;
cmTarget* tgt = this->Makefile->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
te->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& te->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if(!newCMP0022Behavior)
{
std::ostringstream e;
e << "INSTALL(EXPORT) given keyword \""
<< "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \""
<< te->Target->GetName()
<< te->TargetName
<< "\" does not have policy CMP0022 set to NEW.";
this->SetError(e.str());
return false;

View File

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

View File

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