Export: Port interface to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-17 14:33:51 +02:00
parent 1293c1561a
commit 6a72b3c84e
6 changed files with 105 additions and 107 deletions

View File

@ -50,7 +50,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
->FindGeneratorTargetToUse(*tei); ->FindGeneratorTargetToUse(*tei);
expectedTargets += sep + this->Namespace + te->Target->GetExportName(); expectedTargets += sep + this->Namespace + te->Target->GetExportName();
sep = " "; sep = " ";
if(this->ExportedTargets.insert(te->Target).second) if(this->ExportedTargets.insert(te).second)
{ {
this->Exports.push_back(te); this->Exports.push_back(te);
} }
@ -80,45 +80,44 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
tei != this->Exports.end(); ++tei) tei != this->Exports.end(); ++tei)
{ {
cmGeneratorTarget* gte = *tei; cmGeneratorTarget* gte = *tei;
cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, gte);
this->GenerateImportTargetCode(os, te);
te->AppendBuildInterfaceIncludes(); gte->Target->AppendBuildInterfaceIncludes();
ImportPropertyMap properties; ImportPropertyMap properties;
this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te, this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SOURCES", te, this->PopulateInterfaceProperty("INTERFACE_SOURCES", gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te, this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties); gte, properties);
const bool newCMP0022Behavior = const bool newCMP0022Behavior =
te->GetPolicyStatusCMP0022() != cmPolicies::WARN gte->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& te->GetPolicyStatusCMP0022() != cmPolicies::OLD; && gte->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior) if (newCMP0022Behavior)
{ {
this->PopulateInterfaceLinkLibrariesProperty(te, this->PopulateInterfaceLinkLibrariesProperty(gte,
cmGeneratorExpression::BuildInterface, cmGeneratorExpression::BuildInterface,
properties, missingTargets); properties, missingTargets);
} }
this->PopulateCompatibleInterfaceProperties(gte, properties); this->PopulateCompatibleInterfaceProperties(gte, properties);
this->GenerateInterfaceProperties(te, os, properties); this->GenerateInterfaceProperties(gte, os, properties);
} }
// Generate import file content for each configuration. // Generate import file content for each configuration.

View File

@ -155,7 +155,7 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty( void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, const std::string& propName,
cmTarget *target, cmGeneratorTarget *target,
ImportPropertyMap &properties) ImportPropertyMap &properties)
{ {
const char *input = target->GetProperty(propName); const char *input = target->GetProperty(propName);
@ -169,7 +169,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
void cmExportFileGenerator::PopulateInterfaceProperty( void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, const std::string& propName,
const std::string& outputName, const std::string& outputName,
cmTarget *target, cmGeneratorTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule, cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
@ -206,12 +206,12 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
cmTarget *target, cmGeneratorTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule, cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
{ {
if(!target->IsLinkable()) if(!target->Target->IsLinkable())
{ {
return false; return false;
} }
@ -420,7 +420,7 @@ void cmExportFileGenerator::PopulateSourcesInterface(
true); true);
if (!prepro.empty()) if (!prepro.empty())
{ {
this->ResolveTargetsInGeneratorExpressions(prepro, gt->Target, this->ResolveTargetsInGeneratorExpressions(prepro, gt,
missingTargets); missingTargets);
if (!checkInterfaceDirs(prepro, gt, propName)) if (!checkInterfaceDirs(prepro, gt, propName))
@ -488,7 +488,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
true); true);
if (!prepro.empty()) if (!prepro.empty())
{ {
this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets); missingTargets);
if (!checkInterfaceDirs(prepro, target, propName)) if (!checkInterfaceDirs(prepro, target, propName))
@ -502,7 +502,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty( void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, const std::string& propName,
cmTarget *target, cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext preprocessRule, cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
@ -574,15 +574,14 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
cmGeneratorTarget *gtarget, cmGeneratorTarget *gtarget,
ImportPropertyMap &properties) ImportPropertyMap &properties)
{ {
cmTarget *target = gtarget->Target;
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL",
target, properties); gtarget, properties);
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
target, properties); gtarget, properties);
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
target, properties); gtarget, properties);
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
target, properties); gtarget, properties);
std::set<std::string> ifaceProperties; std::set<std::string> ifaceProperties;
@ -593,12 +592,12 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX", getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties); ifaceProperties);
if (target->GetType() != cmState::INTERFACE_LIBRARY) if (gtarget->GetType() != cmState::INTERFACE_LIBRARY)
{ {
getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); getCompatibleInterfaceProperties(gtarget, ifaceProperties, "");
std::vector<std::string> configNames; std::vector<std::string> configNames;
target->GetMakefile()->GetConfigurations(configNames); gtarget->Target->GetMakefile()->GetConfigurations(configNames);
for (std::vector<std::string>::const_iterator ci = configNames.begin(); for (std::vector<std::string>::const_iterator ci = configNames.begin();
ci != configNames.end(); ++ci) ci != configNames.end(); ++ci)
@ -611,19 +610,20 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
it != ifaceProperties.end(); ++it) it != ifaceProperties.end(); ++it)
{ {
this->PopulateInterfaceProperty("INTERFACE_" + *it, this->PopulateInterfaceProperty("INTERFACE_" + *it,
target, properties); gtarget, properties);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, void cmExportFileGenerator::GenerateInterfaceProperties(
const cmGeneratorTarget* target,
std::ostream& os, std::ostream& os,
const ImportPropertyMap &properties) const ImportPropertyMap &properties)
{ {
if (!properties.empty()) if (!properties.empty())
{ {
std::string targetName = this->Namespace; std::string targetName = this->Namespace;
targetName += target->GetExportName(); targetName += target->Target->GetExportName();
os << "set_target_properties(" << targetName << " PROPERTIES\n"; os << "set_target_properties(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin(); for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi) pi != properties.end(); ++pi)
@ -638,12 +638,12 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
cmExportFileGenerator::AddTargetNamespace(std::string &input, cmExportFileGenerator::AddTargetNamespace(std::string &input,
cmTarget* target, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
{ {
cmMakefile *mf = target->GetMakefile(); cmLocalGenerator *lg = target->GetLocalGenerator();
cmTarget *tgt = mf->FindTargetToUse(input); cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input);
if (!tgt) if (!tgt)
{ {
return false; return false;
@ -655,13 +655,14 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input,
} }
if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
{ {
input = this->Namespace + tgt->GetExportName(); input = this->Namespace + tgt->Target->GetExportName();
} }
else else
{ {
std::string namespacedTarget; std::string namespacedTarget;
this->HandleMissingTarget(namespacedTarget, missingTargets, this->HandleMissingTarget(namespacedTarget, missingTargets,
mf, target, tgt); target->Target->GetMakefile(),
target->Target, tgt->Target);
if (!namespacedTarget.empty()) if (!namespacedTarget.empty())
{ {
input = namespacedTarget; input = namespacedTarget;
@ -674,7 +675,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input,
void void
cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
std::string &input, std::string &input,
cmTarget* target, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets, std::vector<std::string> &missingTargets,
FreeTargetsReplace replace) FreeTargetsReplace replace)
{ {
@ -711,14 +712,12 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
void void
cmExportFileGenerator::ResolveTargetsInGeneratorExpression( cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string &input, std::string &input,
cmTarget* target, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
{ {
std::string::size_type pos = 0; std::string::size_type pos = 0;
std::string::size_type lastPos = pos; std::string::size_type lastPos = pos;
cmMakefile *mf = target->GetMakefile();
while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos) while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos)
{ {
std::string::size_type nameStartPos = pos + std::string::size_type nameStartPos = pos +
@ -779,7 +778,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
if (!errorString.empty()) if (!errorString.empty())
{ {
mf->IssueMessage(cmake::FATAL_ERROR, errorString); target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString);
} }
} }
@ -860,7 +859,7 @@ cmExportFileGenerator
preprocessRule); preprocessRule);
if (!prepro.empty()) if (!prepro.empty())
{ {
this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets, missingTargets,
ReplaceFreeTargets); ReplaceFreeTargets);
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
@ -962,7 +961,7 @@ cmExportFileGenerator
sep = ";"; sep = ";";
std::string temp = *li; std::string temp = *li;
this->AddTargetNamespace(temp, target->Target, missingTargets); this->AddTargetNamespace(temp, target, missingTargets);
link_entries += temp; link_entries += temp;
} }
@ -1044,12 +1043,12 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmExportFileGenerator cmExportFileGenerator
::GenerateImportTargetCode(std::ostream& os, cmTarget const* target) ::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target)
{ {
// Construct the imported target name. // Construct the imported target name.
std::string targetName = this->Namespace; std::string targetName = this->Namespace;
targetName += target->GetExportName(); targetName += target->Target->GetExportName();
// Create the imported target. // Create the imported target.
os << "# Create imported target " << targetName << "\n"; os << "# Create imported target " << targetName << "\n";
@ -1078,27 +1077,27 @@ cmExportFileGenerator
} }
// Mark the imported executable if it has exports. // Mark the imported executable if it has exports.
if(target->IsExecutableWithExports()) if(target->Target->IsExecutableWithExports())
{ {
os << "set_property(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY ENABLE_EXPORTS 1)\n"; << " PROPERTY ENABLE_EXPORTS 1)\n";
} }
// Mark the imported library if it is a framework. // Mark the imported library if it is a framework.
if(target->IsFrameworkOnApple()) if(target->Target->IsFrameworkOnApple())
{ {
os << "set_property(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY FRAMEWORK 1)\n"; << " PROPERTY FRAMEWORK 1)\n";
} }
// Mark the imported executable if it is an application bundle. // Mark the imported executable if it is an application bundle.
if(target->IsAppBundleOnApple()) if(target->Target->IsAppBundleOnApple())
{ {
os << "set_property(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY MACOSX_BUNDLE 1)\n"; << " PROPERTY MACOSX_BUNDLE 1)\n";
} }
if (target->IsCFBundleOnApple()) if (target->Target->IsCFBundleOnApple())
{ {
os << "set_property(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY BUNDLE 1)\n"; << " PROPERTY BUNDLE 1)\n";

View File

@ -75,7 +75,8 @@ protected:
const std::string& config = ""); const std::string& config = "");
void GenerateImportFooterCode(std::ostream& os); void GenerateImportFooterCode(std::ostream& os);
void GenerateImportVersionCode(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, void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmTarget const* target, cmTarget const* target,
ImportPropertyMap const& properties); ImportPropertyMap const& properties);
@ -122,19 +123,21 @@ protected:
cmTarget* depender, cmTarget* depender,
cmTarget* dependee) = 0; cmTarget* dependee) = 0;
void PopulateInterfaceProperty(const std::string&, void PopulateInterfaceProperty(const std::string&,
cmTarget *target, cmGeneratorTarget *target,
cmGeneratorExpression::PreprocessContext, cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets); std::vector<std::string> &missingTargets);
bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target, bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext, cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets); std::vector<std::string> &missingTargets);
void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, void PopulateInterfaceProperty(const std::string& propName,
cmGeneratorTarget* target,
ImportPropertyMap &properties); ImportPropertyMap &properties);
void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target,
ImportPropertyMap &properties); ImportPropertyMap &properties);
void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, void GenerateInterfaceProperties(cmGeneratorTarget const* target,
std::ostream& os,
const ImportPropertyMap &properties); const ImportPropertyMap &properties);
void PopulateIncludeDirectoriesInterface( void PopulateIncludeDirectoriesInterface(
cmTargetExport *target, cmTargetExport *target,
@ -159,7 +162,7 @@ protected:
}; };
void ResolveTargetsInGeneratorExpressions(std::string &input, void ResolveTargetsInGeneratorExpressions(std::string &input,
cmTarget* target, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets, std::vector<std::string> &missingTargets,
FreeTargetsReplace replace = NoReplaceFreeTargets); FreeTargetsReplace replace = NoReplaceFreeTargets);
@ -182,20 +185,20 @@ protected:
bool AppendMode; bool AppendMode;
// The set of targets included in the export. // The set of targets included in the export.
std::set<cmTarget*> ExportedTargets; std::set<cmGeneratorTarget*> ExportedTargets;
private: private:
void PopulateInterfaceProperty(const std::string&, const std::string&, void PopulateInterfaceProperty(const std::string&, const std::string&,
cmTarget *target, cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext, cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets); std::vector<std::string> &missingTargets);
bool AddTargetNamespace(std::string &input, cmTarget* target, bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets); std::vector<std::string> &missingTargets);
void ResolveTargetsInGeneratorExpression(std::string &input, void ResolveTargetsInGeneratorExpression(std::string &input,
cmTarget* target, cmGeneratorTarget* target,
std::vector<std::string> &missingTargets); std::vector<std::string> &missingTargets);
virtual void ReplaceInstallPrefix(std::string &input); virtual void ReplaceInstallPrefix(std::string &input);

View File

@ -52,7 +52,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
sep + this->Namespace + (*tei)->Target->Target->GetExportName(); sep + this->Namespace + (*tei)->Target->Target->GetExportName();
sep = " "; sep = " ";
cmTargetExport * te = *tei; cmTargetExport * te = *tei;
if(this->ExportedTargets.insert(te->Target->Target).second) if(this->ExportedTargets.insert(te->Target).second)
{ {
allTargets.push_back(te); allTargets.push_back(te);
} }
@ -133,12 +133,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
tei != allTargets.end(); ++tei) tei != allTargets.end(); ++tei)
{ {
cmGeneratorTarget* gt = (*tei)->Target; cmGeneratorTarget* gt = (*tei)->Target;
cmTarget* te = gt->Target;
requiresConfigFiles = requiresConfigFiles requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmState::INTERFACE_LIBRARY; || gt->GetType() != cmState::INTERFACE_LIBRARY;
this->GenerateImportTargetCode(os, te); this->GenerateImportTargetCode(os, gt);
ImportPropertyMap properties; ImportPropertyMap properties;
@ -149,32 +148,32 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
te, gt,
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
te, gt,
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
te, gt,
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS",
te, gt,
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets); properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
te, gt,
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets); properties, missingTargets);
const bool newCMP0022Behavior = const bool newCMP0022Behavior =
te->GetPolicyStatusCMP0022() != cmPolicies::WARN gt->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN
&& te->GetPolicyStatusCMP0022() != cmPolicies::OLD; && gt->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if (newCMP0022Behavior) if (newCMP0022Behavior)
{ {
if (this->PopulateInterfaceLinkLibrariesProperty(te, if (this->PopulateInterfaceLinkLibrariesProperty(gt,
cmGeneratorExpression::InstallInterface, cmGeneratorExpression::InstallInterface,
properties, missingTargets) properties, missingTargets)
&& !this->ExportOld) && !this->ExportOld)
@ -182,11 +181,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
require2_8_12 = true; require2_8_12 = true;
} }
} }
if (te->GetType() == cmState::INTERFACE_LIBRARY) if (gt->GetType() == cmState::INTERFACE_LIBRARY)
{ {
require3_0_0 = true; 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 // We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1
// can consume them. // can consume them.
@ -194,11 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
} }
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties); gt, properties);
this->PopulateCompatibleInterfaceProperties(gt, properties); this->PopulateCompatibleInterfaceProperties(gt, properties);
this->GenerateInterfaceProperties(gt->Target, os, properties); this->GenerateInterfaceProperties(gt, os, properties);
} }
if (require3_1_0) if (require3_1_0)

View File

@ -28,29 +28,29 @@ cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
{ {
std::set<cmTarget const*> emitted; std::set<cmGeneratorTarget const*> emitted;
std::set<cmTarget const*> emittedDeps; std::set<cmGeneratorTarget const*> emittedDeps;
while(!this->Exports.empty()) while(!this->Exports.empty())
{ {
cmGeneratorTarget const* te = this->Exports.back(); cmGeneratorTarget const* te = this->Exports.back();
this->Exports.pop_back(); this->Exports.pop_back();
if (emitted.insert(te->Target).second) if (emitted.insert(te).second)
{ {
emittedDeps.insert(te->Target); emittedDeps.insert(te);
this->GenerateImportTargetCode(os, te->Target); this->GenerateImportTargetCode(os, te);
ImportPropertyMap properties; ImportPropertyMap properties;
#define FIND_TARGETS(PROPERTY) \ #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) CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
#undef 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; return true;
@ -58,8 +58,8 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
std::string cmExportTryCompileFileGenerator::FindTargets( std::string cmExportTryCompileFileGenerator::FindTargets(
const std::string& propName, const std::string& propName,
cmTarget const* tgt, cmGeneratorTarget const* tgt,
std::set<cmTarget const*> &emitted) std::set<cmGeneratorTarget const*> &emitted)
{ {
const char *prop = tgt->GetProperty(propName); const char *prop = tgt->GetProperty(propName);
if(!prop) if(!prop)
@ -77,24 +77,22 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmTarget dummyHead; cmTarget dummyHead;
dummyHead.SetType(cmState::EXECUTABLE, "try_compile_dummy_exe"); dummyHead.SetType(cmState::EXECUTABLE, "try_compile_dummy_exe");
dummyHead.SetMakefile(tgt->GetMakefile()); dummyHead.SetMakefile(tgt->Target->GetMakefile());
cmGeneratorTarget* gtgt = cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt);
cmGeneratorTarget gDummyHead(&dummyHead, gtgt->GetLocalGenerator());
std::string result = cge->Evaluate(gtgt->GetLocalGenerator(), this->Config, std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
false, &gDummyHead, false, &gDummyHead,
gtgt, &dagChecker); tgt, &dagChecker);
const std::set<cmGeneratorTarget const*> &allTargets = const std::set<cmGeneratorTarget const*> &allTargets =
cge->GetAllTargetsSeen(); cge->GetAllTargetsSeen();
for(std::set<cmGeneratorTarget const*>::const_iterator li = for(std::set<cmGeneratorTarget const*>::const_iterator li =
allTargets.begin(); li != allTargets.end(); ++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; return result;
@ -102,13 +100,12 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, cmExportTryCompileFileGenerator::PopulateProperties(
const cmGeneratorTarget* target,
ImportPropertyMap& properties, ImportPropertyMap& properties,
std::set<cmTarget const*> &emitted) std::set<cmGeneratorTarget const*> &emitted)
{ {
cmPropertyMap props = target->GetProperties(); cmPropertyMap props = target->Target->GetProperties();
cmGeneratorTarget* gt =
target->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(target);
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
{ {
properties[i->first] = i->second.GetValue(); properties[i->first] = i->second.GetValue();
@ -126,8 +123,8 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target,
li != depends.end(); ++li) li != depends.end(); ++li)
{ {
cmGeneratorTarget *tgt = cmGeneratorTarget *tgt =
gt->GetLocalGenerator()->FindGeneratorTargetToUse(*li); target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
if(tgt && emitted.insert(tgt->Target).second) if(tgt && emitted.insert(tgt).second)
{ {
this->Exports.push_back(tgt); this->Exports.push_back(tgt);
} }

View File

@ -41,15 +41,16 @@ protected:
cmTarget*, cmTarget*,
cmTarget*) {} cmTarget*) {}
void PopulateProperties(cmTarget const* target, void PopulateProperties(cmGeneratorTarget const* target,
ImportPropertyMap& properties, ImportPropertyMap& properties,
std::set<cmTarget const*> &emitted); std::set<const cmGeneratorTarget*>& emitted);
std::string InstallNameDir(cmGeneratorTarget* target, std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config); const std::string& config);
private: private:
std::string FindTargets(const std::string& prop, cmTarget const* tgt, std::string FindTargets(const std::string& prop,
std::set<cmTarget const*> &emitted); const cmGeneratorTarget* tgt,
std::set<const cmGeneratorTarget*>& emitted);
std::vector<cmGeneratorTarget const*> Exports; std::vector<cmGeneratorTarget const*> Exports;