Commit 6a72b3c8 authored by Stephen Kelly's avatar Stephen Kelly

Export: Port interface to cmGeneratorTarget.

parent 1293c156
......@@ -50,7 +50,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
->FindGeneratorTargetToUse(*tei);
expectedTargets += sep + this->Namespace + te->Target->GetExportName();
sep = " ";
if(this->ExportedTargets.insert(te->Target).second)
if(this->ExportedTargets.insert(te).second)
{
this->Exports.push_back(te);
}
......@@ -80,45 +80,44 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
tei != this->Exports.end(); ++tei)
{
cmGeneratorTarget* gte = *tei;
cmTarget* te = gte->Target;
this->GenerateImportTargetCode(os, te);
this->GenerateImportTargetCode(os, gte);
te->AppendBuildInterfaceIncludes();
gte->Target->AppendBuildInterfaceIncludes();
ImportPropertyMap properties;
this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te,
this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SOURCES", te,
this->PopulateInterfaceProperty("INTERFACE_SOURCES", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te,
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te,
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te,
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te,
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties);
gte, properties);
const bool newCMP0022Behavior =
te->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& te->GetPolicyStatusCMP0022() != cmPolicies::OLD;
gte->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& gte->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior)
{
this->PopulateInterfaceLinkLibrariesProperty(te,
this->PopulateInterfaceLinkLibrariesProperty(gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
}
this->PopulateCompatibleInterfaceProperties(gte, properties);
this->GenerateInterfaceProperties(te, os, properties);
this->GenerateInterfaceProperties(gte, os, properties);
}
// Generate import file content for each configuration.
......
This diff is collapsed.
......@@ -75,7 +75,8 @@ protected:
const std::string& config = "");
void GenerateImportFooterCode(std::ostream& os);
void GenerateImportVersionCode(std::ostream& os);
void GenerateImportTargetCode(std::ostream& os, cmTarget const* target);
void GenerateImportTargetCode(std::ostream& os,
cmGeneratorTarget const* target);
void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmTarget const* target,
ImportPropertyMap const& properties);
......@@ -122,19 +123,21 @@ protected:
cmTarget* depender,
cmTarget* dependee) = 0;
void PopulateInterfaceProperty(const std::string&,
cmTarget *target,
cmGeneratorTarget *target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target,
bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
void PopulateInterfaceProperty(const std::string& propName, cmTarget *target,
void PopulateInterfaceProperty(const std::string& propName,
cmGeneratorTarget* target,
ImportPropertyMap &properties);
void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target,
ImportPropertyMap &properties);
void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os,
void GenerateInterfaceProperties(cmGeneratorTarget const* target,
std::ostream& os,
const ImportPropertyMap &properties);
void PopulateIncludeDirectoriesInterface(
cmTargetExport *target,
......@@ -159,7 +162,7 @@ protected:
};
void ResolveTargetsInGeneratorExpressions(std::string &input,
cmTarget* target,
cmGeneratorTarget* target,
std::vector<std::string> &missingTargets,
FreeTargetsReplace replace = NoReplaceFreeTargets);
......@@ -182,20 +185,20 @@ protected:
bool AppendMode;
// The set of targets included in the export.
std::set<cmTarget*> ExportedTargets;
std::set<cmGeneratorTarget*> ExportedTargets;
private:
void PopulateInterfaceProperty(const std::string&, const std::string&,
cmTarget *target,
cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
bool AddTargetNamespace(std::string &input, cmTarget* target,
bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets);
void ResolveTargetsInGeneratorExpression(std::string &input,
cmTarget* target,
cmGeneratorTarget* target,
std::vector<std::string> &missingTargets);
virtual void ReplaceInstallPrefix(std::string &input);
......
......@@ -52,7 +52,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
sep + this->Namespace + (*tei)->Target->Target->GetExportName();
sep = " ";
cmTargetExport * te = *tei;
if(this->ExportedTargets.insert(te->Target->Target).second)
if(this->ExportedTargets.insert(te->Target).second)
{
allTargets.push_back(te);
}
......@@ -133,12 +133,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
tei != allTargets.end(); ++tei)
{
cmGeneratorTarget* gt = (*tei)->Target;
cmTarget* te = gt->Target;
requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmState::INTERFACE_LIBRARY;
|| gt->GetType() != cmState::INTERFACE_LIBRARY;
this->GenerateImportTargetCode(os, te);
this->GenerateImportTargetCode(os, gt);
ImportPropertyMap properties;
......@@ -149,32 +148,32 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
te,
gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
te,
gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
te,
gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS",
te,
gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
te,
gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
const bool newCMP0022Behavior =
te->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& te->GetPolicyStatusCMP0022() != cmPolicies::OLD;
gt->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& gt->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior)
{
if (this->PopulateInterfaceLinkLibrariesProperty(te,
if (this->PopulateInterfaceLinkLibrariesProperty(gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets)
&& !this->ExportOld)
......@@ -182,11 +181,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
require2_8_12 = true;
}
}
if (te->GetType() == cmState::INTERFACE_LIBRARY)
if (gt->GetType() == cmState::INTERFACE_LIBRARY)
{
require3_0_0 = true;
}
if(te->GetProperty("INTERFACE_SOURCES"))
if(gt->GetProperty("INTERFACE_SOURCES"))
{
// We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1
// can consume them.
......@@ -194,11 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
}
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties);
gt, properties);
this->PopulateCompatibleInterfaceProperties(gt, properties);
this->GenerateInterfaceProperties(gt->Target, os, properties);
this->GenerateInterfaceProperties(gt, os, properties);
}
if (require3_1_0)
......
......@@ -28,38 +28,38 @@ cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
{
std::set<cmTarget const*> emitted;
std::set<cmTarget const*> emittedDeps;
std::set<cmGeneratorTarget const*> emitted;
std::set<cmGeneratorTarget const*> emittedDeps;
while(!this->Exports.empty())
{
cmGeneratorTarget const* te = this->Exports.back();
this->Exports.pop_back();
if (emitted.insert(te->Target).second)
if (emitted.insert(te).second)
{
emittedDeps.insert(te->Target);
this->GenerateImportTargetCode(os, te->Target);
emittedDeps.insert(te);
this->GenerateImportTargetCode(os, te);
ImportPropertyMap properties;
#define FIND_TARGETS(PROPERTY) \
this->FindTargets("INTERFACE_" #PROPERTY, te->Target, emittedDeps);
this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps);
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
#undef FIND_TARGETS
this->PopulateProperties(te->Target, properties, emittedDeps);
this->PopulateProperties(te, properties, emittedDeps);
this->GenerateInterfaceProperties(te->Target, os, properties);
this->GenerateInterfaceProperties(te, os, properties);
}
}
return true;
}
std::string cmExportTryCompileFileGenerator::FindTargets(
const std::string& propName,
cmTarget const* tgt,
std::set<cmTarget const*> &emitted)
const std::string& propName,
cmGeneratorTarget const* tgt,
std::set<cmGeneratorTarget const*> &emitted)
{
const char *prop = tgt->GetProperty(propName);
if(!prop)
......@@ -77,24 +77,22 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmTarget dummyHead;
dummyHead.SetType(cmState::EXECUTABLE, "try_compile_dummy_exe");
dummyHead.SetMakefile(tgt->GetMakefile());
dummyHead.SetMakefile(tgt->Target->GetMakefile());
cmGeneratorTarget* gtgt =
tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt);
cmGeneratorTarget gDummyHead(&dummyHead, gtgt->GetLocalGenerator());
cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
std::string result = cge->Evaluate(gtgt->GetLocalGenerator(), this->Config,
std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
false, &gDummyHead,
gtgt, &dagChecker);
tgt, &dagChecker);
const std::set<cmGeneratorTarget const*> &allTargets =
cge->GetAllTargetsSeen();
for(std::set<cmGeneratorTarget const*>::const_iterator li =
allTargets.begin(); li != allTargets.end(); ++li)
{
if(emitted.insert((*li)->Target).second)
if(emitted.insert(*li).second)
{
this->Exports.push_back((*li));
this->Exports.push_back(*li);
}
}
return result;
......@@ -102,13 +100,12 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
//----------------------------------------------------------------------------
void
cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target,
ImportPropertyMap& properties,
std::set<cmTarget const*> &emitted)
cmExportTryCompileFileGenerator::PopulateProperties(
const cmGeneratorTarget* target,
ImportPropertyMap& properties,
std::set<cmGeneratorTarget const*> &emitted)
{
cmPropertyMap props = target->GetProperties();
cmGeneratorTarget* gt =
target->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(target);
cmPropertyMap props = target->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
{
properties[i->first] = i->second.GetValue();
......@@ -126,8 +123,8 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target,
li != depends.end(); ++li)
{
cmGeneratorTarget *tgt =
gt->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
if(tgt && emitted.insert(tgt->Target).second)
target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
if(tgt && emitted.insert(tgt).second)
{
this->Exports.push_back(tgt);
}
......
......@@ -41,15 +41,16 @@ protected:
cmTarget*,
cmTarget*) {}
void PopulateProperties(cmTarget const* target,
void PopulateProperties(cmGeneratorTarget const* target,
ImportPropertyMap& properties,
std::set<cmTarget const*> &emitted);
std::set<const cmGeneratorTarget*>& emitted);
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
private:
std::string FindTargets(const std::string& prop, cmTarget const* tgt,
std::set<cmTarget const*> &emitted);
std::string FindTargets(const std::string& prop,
const cmGeneratorTarget* tgt,
std::set<const cmGeneratorTarget*>& emitted);
std::vector<cmGeneratorTarget const*> Exports;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment