Add API to populate INTERFACE properties in exported targets.

The INTERFACE properties need to be preprocessed for context (build
location or install location) and to extract target names etc.
This commit is contained in:
Stephen Kelly
2012-12-10 23:05:11 +01:00
parent e04f737c7a
commit 0c657dc637
2 changed files with 74 additions and 0 deletions
+59
View File
@@ -124,6 +124,65 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
this->GenerateImportTargetsConfig(os, config, suffix);
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
const char *outputName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets)
{
const char *input = target->GetProperty(propName);
if (input)
{
if (!*input)
{
// Set to empty
properties[outputName] = "";
return;
}
std::string prepro = cmGeneratorExpression::Preprocess(input,
preprocessRule);
if (!prepro.empty())
{
this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets);
properties[outputName] = prepro;
}
}
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets)
{
this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
properties, missingTargets);
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target,
std::ostream& os,
const ImportPropertyMap &properties)
{
if (!properties.empty())
{
std::string targetName = this->Namespace;
targetName += target->GetName();
os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi)
{
os << " " << pi->first << " \"" << pi->second << "\"\n";
}
os << ")\n\n";
}
}
//----------------------------------------------------------------------------
void
cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(