cmExportTryCompileFileGenerator: Create cmGeneratorTargets.

This is not a deprecated behavior, but only requires IMPORTED targets
be made.
This commit is contained in:
Stephen Kelly 2015-07-25 20:44:35 +02:00
parent ec38e4c84f
commit 570938cbfd
6 changed files with 36 additions and 17 deletions

View File

@ -379,7 +379,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if (!targets.empty()) if (!targets.empty())
{ {
std::string fname = "/" + std::string(targetName) + "Targets.cmake"; std::string fname = "/" + std::string(targetName) + "Targets.cmake";
cmExportTryCompileFileGenerator tcfg; cmExportTryCompileFileGenerator tcfg(gg);
tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
tcfg.SetExports(targets); tcfg.SetExports(targets);
tcfg.SetConfig(this->Makefile->GetSafeDefinition( tcfg.SetConfig(this->Makefile->GetSafeDefinition(

View File

@ -13,9 +13,16 @@
#include "cmExportTryCompileFileGenerator.h" #include "cmExportTryCompileFileGenerator.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorExpressionDAGChecker.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
cmGlobalGenerator* gg)
{
gg->CreateGenerationObjects(cmGlobalGenerator::ImportedOnly);
}
bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
{ {
std::set<cmTarget const*> emitted; std::set<cmTarget const*> emitted;

View File

@ -20,6 +20,8 @@ class cmInstallTargetGenerator;
class cmExportTryCompileFileGenerator: public cmExportFileGenerator class cmExportTryCompileFileGenerator: public cmExportFileGenerator
{ {
public: public:
cmExportTryCompileFileGenerator(cmGlobalGenerator* gg);
/** Set the list of targets to export. */ /** Set the list of targets to export. */
void SetExports(const std::vector<cmTarget const*> &exports) void SetExports(const std::vector<cmTarget const*> &exports)
{ this->Exports = exports; } { this->Exports = exports; }

View File

@ -1170,11 +1170,11 @@ void cmGlobalGenerator::Configure()
} }
void cmGlobalGenerator::CreateGenerationObjects() void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
{ {
cmDeleteAll(this->GeneratorTargets); cmDeleteAll(this->GeneratorTargets);
this->GeneratorTargets.clear(); this->GeneratorTargets.clear();
this->CreateGeneratorTargets(); this->CreateGeneratorTargets(targetTypes);
} }
cmExportBuildFileGenerator* cmExportBuildFileGenerator*
@ -1485,18 +1485,22 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::CreateGeneratorTargets(cmLocalGenerator *lg) void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
cmLocalGenerator *lg)
{ {
cmGeneratorTargetsType generatorTargets; cmGeneratorTargetsType generatorTargets;
cmMakefile* mf = lg->GetMakefile(); cmMakefile* mf = lg->GetMakefile();
cmTargets& targets = mf->GetTargets(); if (targetTypes == AllTargets)
for(cmTargets::iterator ti = targets.begin();
ti != targets.end(); ++ti)
{ {
cmTarget* t = &ti->second; cmTargets& targets = mf->GetTargets();
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); for(cmTargets::iterator ti = targets.begin();
this->GeneratorTargets[t] = gt; ti != targets.end(); ++ti)
generatorTargets[t] = gt; {
cmTarget* t = &ti->second;
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->GeneratorTargets[t] = gt;
generatorTargets[t] = gt;
}
} }
for(std::vector<cmTarget*>::const_iterator for(std::vector<cmTarget*>::const_iterator
@ -1524,12 +1528,12 @@ void cmGlobalGenerator::InitGeneratorTargets()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::CreateGeneratorTargets() void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
{ {
// Construct per-target generator information. // Construct per-target generator information.
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{ {
this->CreateGeneratorTargets(this->LocalGenerators[i]); this->CreateGeneratorTargets(targetTypes, this->LocalGenerators[i]);
} }
} }

View File

@ -86,7 +86,13 @@ public:
*/ */
virtual void Configure(); virtual void Configure();
void CreateGenerationObjects();
enum TargetTypes {
AllTargets,
ImportedOnly
};
void CreateGenerationObjects(TargetTypes targetTypes = AllTargets);
/** /**
* Generate the all required files for building this project/tree. This * Generate the all required files for building this project/tree. This
@ -491,9 +497,9 @@ private:
// Per-target generator information. // Per-target generator information.
cmGeneratorTargetsType GeneratorTargets; cmGeneratorTargetsType GeneratorTargets;
friend class cmake; friend class cmake;
void CreateGeneratorTargets(cmLocalGenerator* lg); void CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator* lg);
void InitGeneratorTargets(); void InitGeneratorTargets();
void CreateGeneratorTargets(); void CreateGeneratorTargets(TargetTypes targetTypes);
void ClearGeneratorMembers(); void ClearGeneratorMembers();

View File

@ -483,7 +483,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::string linkPath; std::string linkPath;
std::string flags; std::string flags;
std::string linkFlags; std::string linkFlags;
gg->CreateGeneratorTargets(lg.get()); gg->CreateGeneratorTargets(cmGlobalGenerator::AllTargets, lg.get());
cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt); cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
gtgt, false); gtgt, false);