exports: Hold an ExportSet pointer in cm*Export*Generator

Get name from this->ExportSet.
This commit is contained in:
Yury G. Kudryashov 2012-03-01 14:52:32 +04:00 committed by Brad King
parent 5c898fbd99
commit 81cdab5bea
5 changed files with 30 additions and 38 deletions

View File

@ -20,7 +20,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmExportInstallFileGenerator cmExportInstallFileGenerator
::cmExportInstallFileGenerator(cmInstallExportGenerator* iegen): ::cmExportInstallFileGenerator(cmInstallExportGenerator* iegen):
InstallExportGenerator(iegen) IEGen(iegen)
{ {
} }
@ -38,8 +38,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{ {
// Create all the imported targets. // Create all the imported targets.
for(std::vector<cmTargetExport const*>::const_iterator for(std::vector<cmTargetExport const*>::const_iterator
tei = this->ExportSet->GetTargetExports()->begin(); tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
tei != this->ExportSet->GetTargetExports()->end(); ++tei) tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
{ {
cmTargetExport const* te = *tei; cmTargetExport const* te = *tei;
if(this->ExportedTargets.insert(te->Target).second) if(this->ExportedTargets.insert(te->Target).second)
@ -49,8 +49,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
else else
{ {
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT \"" << this->Name << "\" ...) " e << "INSTALL(EXPORT \""
<< "includes target \"" << te->Target->GetName() << this->IEGen->GetExportSet()->GetName()
<< "\" ...) " << "includes target \"" << te->Target->GetName()
<< "\" more than once in the export set."; << "\" more than once in the export set.";
cmSystemTools::Error(e.str().c_str()); cmSystemTools::Error(e.str().c_str());
return false; return false;
@ -86,7 +87,7 @@ bool
cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config)
{ {
// Skip configurations not enabled for this export. // Skip configurations not enabled for this export.
if(!this->InstallExportGenerator->InstallsForConfig(config)) if(!this->IEGen->InstallsForConfig(config))
{ {
return true; return true;
} }
@ -142,7 +143,7 @@ cmExportInstallFileGenerator
{ {
// Add code to compute the installation prefix relative to the // Add code to compute the installation prefix relative to the
// import file location. // import file location.
const char* installDest = this->InstallExportGenerator->GetDestination(); const char* installDest = this->IEGen->GetDestination();
if(!cmSystemTools::FileIsFullPath(installDest)) if(!cmSystemTools::FileIsFullPath(installDest))
{ {
std::string dest = installDest; std::string dest = installDest;
@ -163,8 +164,8 @@ cmExportInstallFileGenerator
// Add each target in the set to the export. // Add each target in the set to the export.
for(std::vector<cmTargetExport const*>::const_iterator for(std::vector<cmTargetExport const*>::const_iterator
tei = this->ExportSet->GetTargetExports()->begin(); tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
tei != this->ExportSet->GetTargetExports()->end(); ++tei) tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
{ {
// Collect import properties for this target. // Collect import properties for this target.
cmTargetExport const* te = *tei; cmTargetExport const* te = *tei;
@ -311,9 +312,11 @@ void
cmExportInstallFileGenerator cmExportInstallFileGenerator
::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen) ::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen)
{ {
const char* installDest = this->InstallExportGenerator->GetDestination(); const char* installDest = this->IEGen->GetDestination();
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT \"" << this->Name << "\") given absolute " e << "INSTALL(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\") given absolute "
<< "DESTINATION \"" << installDest << "\" but the export " << "DESTINATION \"" << installDest << "\" but the export "
<< "references an installation of target \"" << "references an installation of target \""
<< itgen->GetTarget()->GetName() << "\" which has relative " << itgen->GetTarget()->GetName() << "\" which has relative "
@ -327,7 +330,9 @@ cmExportInstallFileGenerator
::ComplainAboutMissingTarget(cmTarget* depender, cmTarget* dependee) ::ComplainAboutMissingTarget(cmTarget* depender, cmTarget* dependee)
{ {
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT \"" << this->Name << "\" ...) " e << "INSTALL(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\" ...) "
<< "includes target \"" << depender->GetName() << "includes target \"" << depender->GetName()
<< "\" which requires target \"" << dependee->GetName() << "\" which requires target \"" << dependee->GetName()
<< "\" that is not in the export set."; << "\" that is not in the export set.";

View File

@ -41,15 +41,6 @@ public:
files. */ files. */
cmExportInstallFileGenerator(cmInstallExportGenerator* iegen); cmExportInstallFileGenerator(cmInstallExportGenerator* iegen);
/** Set the name of the export associated with the files. This is
the name given to the install(EXPORT) command mode. */
void SetName(const char* name) { this->Name = name; }
/** Set the set of targets to be exported. These are the targets
associated with the export name. */
void SetExportSet(cmExportSet const* eSet)
{ this->ExportSet = eSet; }
/** Get the per-config file generated for each configuraiton. This /** Get the per-config file generated for each configuraiton. This
maps from the configuration name to the file temporary location maps from the configuration name to the file temporary location
for installation. */ for installation. */
@ -82,9 +73,7 @@ protected:
void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen); void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
cmInstallExportGenerator* InstallExportGenerator; cmInstallExportGenerator* IEGen;
std::string Name;
cmExportSet const* ExportSet;
std::string ImportPrefix; std::string ImportPrefix;

View File

@ -1271,7 +1271,9 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Create the export install generator. // Create the export install generator.
cmInstallExportGenerator* exportGenerator = cmInstallExportGenerator* exportGenerator =
new cmInstallExportGenerator( new cmInstallExportGenerator(
exp.GetCString(), ica.GetDestination().c_str(), this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GetExportSets()[exp.GetString()],
ica.GetDestination().c_str(),
ica.GetPermissions().c_str(), ica.GetConfigurations(), ica.GetPermissions().c_str(), ica.GetConfigurations(),
ica.GetComponent().c_str(), fname.c_str(), ica.GetComponent().c_str(), fname.c_str(),
name_space.GetCString(), this->Makefile); name_space.GetCString(), this->Makefile);

View File

@ -27,7 +27,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmInstallExportGenerator::cmInstallExportGenerator( cmInstallExportGenerator::cmInstallExportGenerator(
const char* name, cmExportSet* exportSet,
const char* destination, const char* destination,
const char* file_permissions, const char* file_permissions,
std::vector<std::string> const& configurations, std::vector<std::string> const& configurations,
@ -35,7 +35,7 @@ cmInstallExportGenerator::cmInstallExportGenerator(
const char* filename, const char* name_space, const char* filename, const char* name_space,
cmMakefile* mf) cmMakefile* mf)
:cmInstallGenerator(destination, configurations, component) :cmInstallGenerator(destination, configurations, component)
,Name(name) ,ExportSet(exportSet)
,FilePermissions(file_permissions) ,FilePermissions(file_permissions)
,FileName(filename) ,FileName(filename)
,Namespace(name_space) ,Namespace(name_space)
@ -114,16 +114,12 @@ void cmInstallExportGenerator::ComputeTempDir()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmInstallExportGenerator::GenerateScript(std::ostream& os) void cmInstallExportGenerator::GenerateScript(std::ostream& os)
{ {
// Get the export set requested.
cmExportSet const* exportSet =
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->GetExportSets()[this->Name];
// Skip empty sets. // Skip empty sets.
if(!exportSet) if(ExportSet->GetTargetExports()->empty())
{ {
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT) given unknown export \"" << this->Name << "\""; e << "INSTALL(EXPORT) given unknown export \""
<< ExportSet->GetName() << "\"";
cmSystemTools::Error(e.str().c_str()); cmSystemTools::Error(e.str().c_str());
return; return;
} }
@ -138,8 +134,6 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
this->MainImportFile += this->FileName; this->MainImportFile += this->FileName;
// Generate the import file for this export set. // Generate the import file for this export set.
this->EFGen->SetName(this->Name.c_str());
this->EFGen->SetExportSet(exportSet);
this->EFGen->SetExportFile(this->MainImportFile.c_str()); this->EFGen->SetExportFile(this->MainImportFile.c_str());
this->EFGen->SetNamespace(this->Namespace.c_str()); this->EFGen->SetNamespace(this->Namespace.c_str());
if(this->ConfigurationTypes->empty()) if(this->ConfigurationTypes->empty())

View File

@ -26,13 +26,15 @@ class cmMakefile;
class cmInstallExportGenerator: public cmInstallGenerator class cmInstallExportGenerator: public cmInstallGenerator
{ {
public: public:
cmInstallExportGenerator(const char* name, cmInstallExportGenerator(cmExportSet* exportSet,
const char* dest, const char* file_permissions, const char* dest, const char* file_permissions,
const std::vector<std::string>& configurations, const std::vector<std::string>& configurations,
const char* component, const char* component,
const char* filename, const char* name_space, const char* filename, const char* name_space,
cmMakefile* mf); cmMakefile* mf);
~cmInstallExportGenerator(); ~cmInstallExportGenerator();
cmExportSet* GetExportSet() {return ExportSet;}
protected: protected:
virtual void GenerateScript(std::ostream& os); virtual void GenerateScript(std::ostream& os);
virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
@ -41,7 +43,7 @@ protected:
void GenerateImportFile(const char* config, cmExportSet const* exportSet); void GenerateImportFile(const char* config, cmExportSet const* exportSet);
void ComputeTempDir(); void ComputeTempDir();
std::string Name; cmExportSet* ExportSet;
std::string FilePermissions; std::string FilePermissions;
std::string FileName; std::string FileName;
std::string Namespace; std::string Namespace;