diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-12-10 22:05:11 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-01-05 00:18:36 (GMT) |
commit | 0c657dc637ca4da6861102c7306069ad157ec08d (patch) | |
tree | 453f107522f1bc9953717c9611960aea1b21fdf7 /Source | |
parent | e04f737c7a3e66c49e2d50813af1fa40a415eff8 (diff) | |
download | CMake-0c657dc637ca4da6861102c7306069ad157ec08d.zip CMake-0c657dc637ca4da6861102c7306069ad157ec08d.tar.gz CMake-0c657dc637ca4da6861102c7306069ad157ec08d.tar.bz2 |
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.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 59 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.h | 15 |
2 files changed, 74 insertions, 0 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 2507b72..2b133be 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -125,6 +125,65 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, } //---------------------------------------------------------------------------- +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( std::string &input, diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 0b89a64..7c58ad8 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -13,6 +13,7 @@ #define cmExportFileGenerator_h #include "cmCommand.h" +#include "cmGeneratorExpression.h" /** \class cmExportFileGenerator * \brief Generate a file exporting targets from a build or install tree. @@ -93,6 +94,13 @@ protected: cmMakefile* mf, cmTarget* depender, cmTarget* dependee) = 0; + void PopulateInterfaceProperty(const char *, + cmTarget *target, + cmGeneratorExpression::PreprocessContext, + ImportPropertyMap &properties, + std::vector<std::string> &missingTargets); + void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, + const ImportPropertyMap &properties); void ResolveTargetsInGeneratorExpressions(std::string &input, cmTarget* target, @@ -113,6 +121,13 @@ protected: // The set of targets included in the export. std::set<cmTarget*> ExportedTargets; + +private: + void PopulateInterfaceProperty(const char *, const char *, + cmTarget *target, + cmGeneratorExpression::PreprocessContext, + ImportPropertyMap &properties, + std::vector<std::string> &missingTargets); }; #endif |