diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionDAGChecker.cxx | 8 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionDAGChecker.h | 6 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 77 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 3 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 144 | ||||
-rw-r--r-- | Source/cmTarget.h | 3 |
8 files changed, 237 insertions, 11 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 50835e2..0d0d05b 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -77,6 +77,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, cmGeneratorExpression::BuildInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, + cmGeneratorExpression::BuildInterface, + properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); const bool newCMP0022Behavior = diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index ad17556..79e78df 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -140,6 +140,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", + te, + cmGeneratorExpression::InstallInterface, + properties, missingTargets); const bool newCMP0022Behavior = te->GetPolicyStatusCMP0022() != cmPolicies::WARN diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 7399c7b..92f74f3 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -210,3 +210,11 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const return (strcmp(prop, "COMPILE_OPTIONS") == 0 || strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 ); } + +//---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::EvaluatingAutoUicOptions() const +{ + const char *prop = this->Property.c_str(); + return (strcmp(prop, "AUTOUIC_OPTIONS") == 0 + || strcmp(prop, "INTERFACE_AUTOUIC_OPTIONS") == 0 ); +} diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index c8594e7..fd47ad7 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -20,13 +20,15 @@ F(EvaluatingIncludeDirectories) \ F(EvaluatingSystemIncludeDirectories) \ F(EvaluatingCompileDefinitions) \ - F(EvaluatingCompileOptions) + F(EvaluatingCompileOptions) \ + F(EvaluatingAutoUicOptions) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ F(INCLUDE_DIRECTORIES) \ F(SYSTEM_INCLUDE_DIRECTORIES) \ F(COMPILE_DEFINITIONS) \ - F(COMPILE_OPTIONS) + F(COMPILE_OPTIONS) \ + F(AUTOUIC_OPTIONS) //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker 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; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 116f174..e877f7d 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -31,7 +31,8 @@ private: const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines); - void SetupAutoUicTarget(cmTarget* target); + void SetupAutoUicTarget(cmTarget* target, + std::map<std::string, std::string> &configUicOptions); void SetupAutoRccTarget(cmTarget* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2423b27..fe68a8a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -135,6 +135,7 @@ public: }; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; + std::vector<TargetPropertyEntry*> AutoUicOptionsEntries; std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries; @@ -143,11 +144,14 @@ public: mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileOptionsEntries; mutable std::map<std::string, std::vector<TargetPropertyEntry*> > + CachedLinkInterfaceAutoUicOptionsEntries; + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileDefinitionsEntries; mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone; + mutable std::map<std::string, bool> CacheLinkInterfaceAutoUicOptionsDone; }; //---------------------------------------------------------------------------- @@ -182,6 +186,7 @@ cmTargetInternals::~cmTargetInternals() { deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); + deleteAndClear(this->CachedLinkInterfaceAutoUicOptionsEntries); deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); } @@ -1473,6 +1478,17 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } + if(strcmp(prop,"AUTOUIC_OPTIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + deleteAndClear(this->Internal->AutoUicOptionsEntries); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); + this->Internal->AutoUicOptionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { cmListFileBacktrace lfbt; @@ -1547,6 +1563,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } + if(strcmp(prop,"AUTOUIC_OPTIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->AutoUicOptionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + return; + } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { cmListFileBacktrace lfbt; @@ -2043,6 +2068,106 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- +void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const +{ + std::set<std::string> uniqueOptions; + cmListFileBacktrace lfbt; + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "AUTOUIC_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugAutoUicOptionsDone = true; + } + + processCompileOptions(this, + this->Internal->AutoUicOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions); + + std::string configString = config ? config : ""; + if (!this->Internal->CacheLinkInterfaceAutoUicOptionsDone[configString]) + { + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkInterfacePropertyEntries.begin(), + end = this->Internal->LinkInterfacePropertyEntries.end(); + it != end; ++it) + { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(it->Value); + std::string targetResult = cge->Evaluate(this->Makefile, config, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + { + continue; + } + } + std::string optionGenex = "$<TARGET_PROPERTY:" + + it->Value + ",INTERFACE_AUTOUIC_OPTIONS>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">"; + } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( + optionGenex); + + this->Internal + ->CachedLinkInterfaceAutoUicOptionsEntries[configString].push_back( + new cmTargetInternals::TargetPropertyEntry(cge, + it->Value)); + } + } + + processCompileOptions(this, + this->Internal->CachedLinkInterfaceAutoUicOptionsEntries[configString], + result, + uniqueOptions, + &dagChecker, + config, + debugOptions); + + if (!this->Makefile->IsGeneratingBuildSystem()) + { + deleteAndClear(this->Internal->CachedLinkInterfaceAutoUicOptionsEntries); + } + else + { + this->Internal->CacheLinkInterfaceAutoUicOptionsDone[configString] = true; + } +} + +//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, const char *config) const { @@ -2749,6 +2874,24 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } + if(strcmp(prop,"AUTOUIC_OPTIONS") == 0) + { + static std::string output; + output = ""; + std::string sep; + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for (std::vector<TargetPropertyEntry*>::const_iterator + it = this->Internal->AutoUicOptionsEntries.begin(), + end = this->Internal->AutoUicOptionsEntries.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } + return output.c_str(); + } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { static std::string output; @@ -5958,6 +6101,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { deleteAndClear(this->Pointer->IncludeDirectoriesEntries); deleteAndClear(this->Pointer->CompileOptionsEntries); + deleteAndClear(this->Pointer->AutoUicOptionsEntries); deleteAndClear(this->Pointer->CompileDefinitionsEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 35ec680..c70409c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -532,6 +532,8 @@ public: void GetCompileOptions(std::vector<std::string> &result, const char *config) const; + void GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, @@ -689,6 +691,7 @@ private: bool IsImportedTarget; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; + mutable bool DebugAutoUicOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; |