diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-11-20 13:54:39 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-11-27 18:06:12 (GMT) |
commit | 98093c45db3327dc92879670ef22dc4001392480 (patch) | |
tree | 22ecf099ed3a3bca016e22c3ed9f56756b302583 /Source/cmQtAutoGenerators.cxx | |
parent | 02542b4cc73a12be8c1d3f583340400dd761ce24 (diff) | |
download | CMake-98093c45db3327dc92879670ef22dc4001392480.zip CMake-98093c45db3327dc92879670ef22dc4001392480.tar.gz CMake-98093c45db3327dc92879670ef22dc4001392480.tar.bz2 |
QtAutoUic: Add INTERFACE_AUTOUIC_OPTIONS target property.
Transitively consume the property from linked dependents.
Implement configuration-specific support by following the pattern
set out for compile definitions and includes in cmQtAutoGenerators.
Implement support for origin-tracking with CMAKE_DEBUG_TARGET_PROPERTIES.
This is motivated by the needs of KDE, which provides a separate
translation system based on gettext instead of the Qt linguist
translation system. The Qt uic tool provides command line options
for configuring the method used to translate text, and to add an
include directive to the generated file to provide the method.
http://thread.gmane.org/gmane.comp.kde.devel.frameworks/7930/focus=7992
Implement the interface to provide the uic options as a usage-requirement
on the KI18n target, as designed for KDE.
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 77 |
1 files changed, 69 insertions, 8 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 576883f..835e3b4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -365,6 +365,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) std::map<std::string, std::string> configIncludes; std::map<std::string, std::string> configDefines; + std::map<std::string, std::string> configUicOptions; if (target->GetPropertyAsBool("AUTOMOC")) { @@ -373,7 +374,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) } if (target->GetPropertyAsBool("AUTOUIC")) { - this->SetupAutoUicTarget(target); + this->SetupAutoUicTarget(target, configUicOptions); } if (target->GetPropertyAsBool("AUTORCC")) { @@ -388,7 +389,9 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), false, true, false); - if (!configDefines.empty() || !configIncludes.empty()) + if (!configDefines.empty() + || !configIncludes.empty() + || !configUicOptions.empty()) { std::ofstream infoFile(outputFile.c_str(), std::ios::app); if ( !infoFile ) @@ -419,6 +422,16 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) " " << it->second << ")\n"; } } + if (!configUicOptions.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configUicOptions.begin(), end = configUicOptions.end(); + it != end; ++it) + { + infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << + " " << it->second << ")\n"; + } + } } } @@ -601,7 +614,25 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target) +static void GetUicOpts(cmTarget *target, const char * config, + std::string &optString) +{ + std::vector<std::string> opts; + target->GetAutoUicOptions(opts, config); + + const char* sep = ""; + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) + { + optString += sep; + sep = ";"; + optString += *optIt; + } +} + +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target, + std::map<std::string, std::string> &configUicOptions) { cmMakefile *makefile = target->GetMakefile(); @@ -650,10 +681,30 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target) const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - if (const char* opts = target->GetProperty("AUTOUIC_OPTIONS")) + std::string _uic_opts; + std::vector<std::string> configs; + const char *config = makefile->GetConfigurations(configs); + GetUicOpts(target, config, _uic_opts); + + if (!_uic_opts.empty()) + { + _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str()); + makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); + } + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) { - makefile->AddDefinition("_uic_target_options", - cmLocalGenerator::EscapeForCMake(opts).c_str()); + std::string config_uic_opts; + GetUicOpts(target, li->c_str(), config_uic_opts); + if (config_uic_opts != _uic_opts) + { + configUicOptions[*li] = + cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str()); + if(_uic_opts.empty()) + { + _uic_opts = config_uic_opts; + } + } } for(std::vector<cmSourceFile*>::const_iterator fileIt = @@ -972,9 +1023,19 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, { const char *uicOptionsFiles = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); + std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS"; + std::string uicOptionsProp = uicOptionsPropOrig; + if(config) + { + uicOptionsProp += "_"; + uicOptionsProp += config; + } const char *uicTargetOptions - = makefile->GetSafeDefinition("AM_UIC_TARGET_OPTIONS"); - cmSystemTools::ExpandListArgument(uicTargetOptions, this->UicTargetOptions); + = makefile->GetSafeDefinition(uicOptionsProp.c_str()); + cmSystemTools::ExpandListArgument( + uicTargetOptions ? uicTargetOptions + : makefile->GetSafeDefinition(includesPropOrig.c_str()), + this->UicTargetOptions); const char *uicOptionsOptions = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); std::vector<std::string> uicFilesVec; |