cmMakefile: Store container of cmExportBuildFileGenerators.
Set a cmLocalGenerator on each instance at compute time. That will soon be needed to access cmGeneratorTarget instances. If a cmExportBuildFileGenerator is processed early during configure time as a result of CMP0024 it must be removed from the list to process later at generate time.
This commit is contained in:
parent
1583440509
commit
488723f5cd
|
@ -18,12 +18,17 @@
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
cmExportBuildFileGenerator::cmExportBuildFileGenerator()
|
||||
: Backtrace()
|
||||
{
|
||||
this->Makefile = 0;
|
||||
this->LG = 0;
|
||||
this->ExportSet = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg)
|
||||
{
|
||||
this->LG = lg;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
|
||||
{
|
||||
|
@ -37,7 +42,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
|
|||
tei = targets.begin();
|
||||
tei != targets.end(); ++tei)
|
||||
{
|
||||
cmGeneratorTarget *te = this->Makefile
|
||||
cmGeneratorTarget *te = this->LG->GetMakefile()
|
||||
->FindGeneratorTargetToUse(*tei);
|
||||
expectedTargets += sep + this->Namespace + te->Target->GetExportName();
|
||||
sep = " ";
|
||||
|
@ -49,8 +54,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
|
|||
{
|
||||
std::ostringstream e;
|
||||
e << "given target \"" << te->GetName() << "\" more than once.";
|
||||
this->Makefile->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
|
||||
this->LG->GetGlobalGenerator()->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||
this->LG->GetMakefile()->GetBacktrace());
|
||||
return false;
|
||||
}
|
||||
if (te->GetType() == cmTarget::INTERFACE_LIBRARY)
|
||||
|
@ -328,8 +334,9 @@ cmExportBuildFileGenerator
|
|||
e << "If the required target is not easy to reference in this call, "
|
||||
<< "consider using the APPEND option with multiple separate calls.";
|
||||
|
||||
this->Makefile->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
|
||||
this->LG->GetGlobalGenerator()->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||
this->LG->GetMakefile()->GetBacktrace());
|
||||
}
|
||||
|
||||
std::string
|
||||
|
|
|
@ -43,10 +43,7 @@ public:
|
|||
/** Set whether to append generated code to the output file. */
|
||||
void SetAppendMode(bool append) { this->AppendMode = append; }
|
||||
|
||||
void SetMakefile(cmMakefile *mf) {
|
||||
this->Makefile = mf;
|
||||
this->Backtrace = this->Makefile->GetBacktrace();
|
||||
}
|
||||
void Compute(cmLocalGenerator* lg);
|
||||
|
||||
protected:
|
||||
// Implement virtual methods from the superclass.
|
||||
|
@ -80,8 +77,7 @@ protected:
|
|||
std::vector<std::string> Targets;
|
||||
cmExportSet *ExportSet;
|
||||
std::vector<cmGeneratorTarget*> Exports;
|
||||
cmMakefile* Makefile;
|
||||
cmListFileBacktrace Backtrace;
|
||||
cmLocalGenerator* LG;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -221,7 +221,7 @@ bool cmExportCommand
|
|||
{
|
||||
ebfg->SetTargets(targets);
|
||||
}
|
||||
ebfg->SetMakefile(this->Makefile);
|
||||
this->Makefile->AddExportBuildFileGenerator(ebfg);
|
||||
ebfg->SetExportOld(this->ExportOld.IsEnabled());
|
||||
|
||||
// Compute the set of configurations exported.
|
||||
|
|
|
@ -73,7 +73,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
|
|||
this->CurrentMakefile = 0;
|
||||
this->TryCompileOuterMakefile = 0;
|
||||
|
||||
this->ConfigureDoneCMP0026 = false;
|
||||
this->ConfigureDoneCMP0026AndCMP0024 = false;
|
||||
}
|
||||
|
||||
cmGlobalGenerator::~cmGlobalGenerator()
|
||||
|
@ -234,6 +234,16 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string &file)
|
|||
if (it != this->BuildExportSets.end())
|
||||
{
|
||||
bool result = it->second->GenerateImportFile();
|
||||
|
||||
if (!this->ConfigureDoneCMP0026AndCMP0024)
|
||||
{
|
||||
for (std::vector<cmMakefile*>::const_iterator mit =
|
||||
this->Makefiles.begin(); mit != this->Makefiles.end(); ++mit)
|
||||
{
|
||||
(*mit)->RemoveExportBuildFileGeneratorCMP0024(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
delete it->second;
|
||||
it->second = 0;
|
||||
this->BuildExportSets.erase(it);
|
||||
|
@ -1122,11 +1132,11 @@ void cmGlobalGenerator::Configure()
|
|||
this->CMakeInstance->GetHomeOutputDirectory());
|
||||
|
||||
// now do it
|
||||
this->ConfigureDoneCMP0026 = false;
|
||||
this->ConfigureDoneCMP0026AndCMP0024 = false;
|
||||
dirMf->Configure();
|
||||
dirMf->EnforceDirectoryLevelRules();
|
||||
|
||||
this->ConfigureDoneCMP0026 = true;
|
||||
this->ConfigureDoneCMP0026AndCMP0024 = true;
|
||||
|
||||
// Put a copy of each global target in every directory.
|
||||
cmTargets globalTargets;
|
||||
|
@ -1226,6 +1236,20 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::ComputeBuildFileGenerators()
|
||||
{
|
||||
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
||||
{
|
||||
std::vector<cmExportBuildFileGenerator*> gens =
|
||||
this->Makefiles[i]->GetExportBuildFileGenerators();
|
||||
for (std::vector<cmExportBuildFileGenerator*>::const_iterator it =
|
||||
gens.begin(); it != gens.end(); ++it)
|
||||
{
|
||||
(*it)->Compute(this->LocalGenerators[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool cmGlobalGenerator::Compute()
|
||||
{
|
||||
// Some generators track files replaced during the Generate.
|
||||
|
@ -1255,6 +1279,8 @@ bool cmGlobalGenerator::Compute()
|
|||
this->CreateQtAutoGeneratorsTargets();
|
||||
#endif
|
||||
|
||||
this->ComputeBuildFileGenerators();
|
||||
|
||||
unsigned int i;
|
||||
|
||||
// Add generator specific helper commands
|
||||
|
|
|
@ -362,7 +362,10 @@ public:
|
|||
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
|
||||
#endif
|
||||
|
||||
bool GetConfigureDoneCMP0026() const { return this->ConfigureDoneCMP0026; }
|
||||
bool GetConfigureDoneCMP0026() const
|
||||
{ return this->ConfigureDoneCMP0026AndCMP0024; }
|
||||
|
||||
void ComputeBuildFileGenerators();
|
||||
|
||||
std::string MakeSilentFlag;
|
||||
protected:
|
||||
|
@ -520,7 +523,7 @@ protected:
|
|||
bool ForceUnixPaths;
|
||||
bool ToolSupportsColor;
|
||||
bool InstallTargetEnabled;
|
||||
bool ConfigureDoneCMP0026;
|
||||
bool ConfigureDoneCMP0026AndCMP0024;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -126,6 +126,7 @@ bool cmIncludeCommand
|
|||
}
|
||||
}
|
||||
gg->CreateGenerationObjects();
|
||||
gg->ComputeBuildFileGenerators();
|
||||
gg->GenerateImportFile(fname_abs);
|
||||
}
|
||||
|
||||
|
|
|
@ -702,6 +702,29 @@ cmMakefile::GetEvaluationFiles() const
|
|||
return this->EvaluationFiles;
|
||||
}
|
||||
|
||||
std::vector<cmExportBuildFileGenerator*>
|
||||
cmMakefile::GetExportBuildFileGenerators() const
|
||||
{
|
||||
return this->ExportBuildFileGenerators;
|
||||
}
|
||||
|
||||
void cmMakefile::RemoveExportBuildFileGeneratorCMP0024(
|
||||
cmExportBuildFileGenerator* gen)
|
||||
{
|
||||
std::vector<cmExportBuildFileGenerator*>::iterator it =
|
||||
std::find(this->ExportBuildFileGenerators.begin(),
|
||||
this->ExportBuildFileGenerators.end(), gen);
|
||||
if(it != this->ExportBuildFileGenerators.end())
|
||||
{
|
||||
this->ExportBuildFileGenerators.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefile::AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen)
|
||||
{
|
||||
this->ExportBuildFileGenerators.push_back(gen);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct file_not_persistent
|
||||
|
|
|
@ -51,6 +51,7 @@ class cmake;
|
|||
class cmMakefileCall;
|
||||
class cmCMakePolicyCommand;
|
||||
class cmGeneratorExpressionEvaluationFile;
|
||||
class cmExportBuildFileGenerator;
|
||||
|
||||
/** \class cmMakefile
|
||||
* \brief Process the input CMakeLists.txt file.
|
||||
|
@ -789,6 +790,11 @@ public:
|
|||
bool inputIsContent);
|
||||
std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const;
|
||||
|
||||
std::vector<cmExportBuildFileGenerator*>
|
||||
GetExportBuildFileGenerators() const;
|
||||
void RemoveExportBuildFileGeneratorCMP0024(cmExportBuildFileGenerator* gen);
|
||||
void AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen);
|
||||
|
||||
protected:
|
||||
// add link libraries and directories to the target
|
||||
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
|
||||
|
@ -882,6 +888,7 @@ private:
|
|||
mutable cmsys::RegularExpression cmNamedCurly;
|
||||
|
||||
std::vector<cmMakefile*> UnConfiguredDirectories;
|
||||
std::vector<cmExportBuildFileGenerator*> ExportBuildFileGenerators;
|
||||
|
||||
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
|
||||
|
||||
|
|
Loading…
Reference in New Issue