From 77f3772784152701ff0eee5e4a19177996c03c0e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 3 Dec 2013 13:26:51 +0100 Subject: cmTarget: Require a compatible INTERFACE_AUTOUIC_OPTIONS from dependencies. Revert the origin-tracking infrastructure from commit 98093c45 (QtAutoUic: Add INTERFACE_AUTOUIC_OPTIONS target property., 2013-11-20). Use the compatibility-tracking for compatible strings instead. If two different dependencies require different AUTOUIC_OPTIONS, cmake will now appropriately issue an error. --- Source/cmTarget.cxx | 169 ++++----------------- Source/cmTarget.h | 1 - Tests/RunCMake/CMakeLists.txt | 3 + .../CompatibleInterface/AutoUic-result.txt | 1 + .../CompatibleInterface/AutoUic-stderr.txt | 11 ++ Tests/RunCMake/CompatibleInterface/AutoUic.cmake | 22 +++ .../CompatibleInterface/RunCMakeTest.cmake | 5 + Tests/RunCMake/CompatibleInterface/empty.cpp | 1 + 8 files changed, 69 insertions(+), 144 deletions(-) create mode 100644 Tests/RunCMake/CompatibleInterface/AutoUic-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/AutoUic.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/empty.cpp diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7c0cdc3..28de897 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -135,7 +135,6 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; - std::vector AutoUicOptionsEntries; std::vector CompileDefinitionsEntries; std::vector LinkInterfacePropertyEntries; @@ -144,14 +143,11 @@ public: mutable std::map > CachedLinkInterfaceCompileOptionsEntries; mutable std::map > - CachedLinkInterfaceAutoUicOptionsEntries; - mutable std::map > CachedLinkInterfaceCompileDefinitionsEntries; mutable std::map CacheLinkInterfaceIncludeDirectoriesDone; mutable std::map CacheLinkInterfaceCompileDefinitionsDone; mutable std::map CacheLinkInterfaceCompileOptionsDone; - mutable std::map CacheLinkInterfaceAutoUicOptionsDone; }; //---------------------------------------------------------------------------- @@ -186,7 +182,6 @@ cmTargetInternals::~cmTargetInternals() { deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); - deleteAndClear(this->CachedLinkInterfaceAutoUicOptionsEntries); deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); } @@ -1478,17 +1473,6 @@ 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 cge = ge.Parse(value); - this->Internal->AutoUicOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); - return; - } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { cmListFileBacktrace lfbt; @@ -1563,15 +1547,6 @@ 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; @@ -2071,100 +2046,26 @@ static void processCompileOptions(cmTarget const* tgt, void cmTarget::GetAutoUicOptions(std::vector &result, const char *config) const { - std::set uniqueOptions; - cmListFileBacktrace lfbt; - - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - - std::vector 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]) + const char *prop + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) { - for (std::vector::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 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 = "$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 = "$<$Value + ">:" + optionGenex + ">"; - } - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr cge = ge.Parse( - optionGenex); - - this->Internal - ->CachedLinkInterfaceAutoUicOptionsEntries[configString].push_back( - new cmTargetInternals::TargetPropertyEntry(cge, - it->Value)); - } + return; } + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); - 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; - } + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker), + result); } //---------------------------------------------------------------------------- @@ -2874,24 +2775,6 @@ 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::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; @@ -4503,7 +4386,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant) { case BoolType: case StringType: - return "(Agree)\n"; + return dominant ? "(Disagree)\n" : "(Agree)\n"; case NumberMaxType: case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; @@ -4594,6 +4477,8 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { PropertyType consistent = consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent); if (!consistent) { cmOStringStream e; @@ -4606,8 +4491,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent); propContent = consistent; continue; } @@ -4632,6 +4515,8 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { PropertyType consistent = consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent); if (!consistent) { cmOStringStream e; @@ -4645,8 +4530,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent); propContent = consistent; continue; } @@ -4665,6 +4548,8 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { PropertyType consistent = consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent); if (!consistent) { cmOStringStream e; @@ -4677,8 +4562,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent); propContent = consistent; continue; } @@ -4813,7 +4696,8 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, { return false; } - return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", + return (p == "AUTOUIC_OPTIONS") || + isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", config); } @@ -6232,7 +6116,6 @@ 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 2f4be84..3f5a5d1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -698,7 +698,6 @@ private: mutable bool DebugIncludesDone; mutable std::map DebugCompatiblePropertiesDone; mutable bool DebugCompileOptionsDone; - mutable bool DebugAutoUicOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable std::set LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 593921f..96b0543 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -94,6 +94,9 @@ if(NOT WIN32) add_RunCMake_test(VisibilityPreset) endif() endif() +if (QT4_FOUND) + set(CompatibleInterface_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) +endif() add_RunCMake_test(CompatibleInterface) add_RunCMake_test(Syntax) diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic-result.txt b/Tests/RunCMake/CompatibleInterface/AutoUic-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/AutoUic-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt b/Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt new file mode 100644 index 0000000..09f9461 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt @@ -0,0 +1,11 @@ +CMake Error: The INTERFACE_AUTOUIC_OPTIONS property of "OtherI18n" does +not agree with the value of AUTOUIC_OPTIONS already determined +for "LibWidget". + +CMake Debug Log: + String compatibility of property "AUTOUIC_OPTIONS" for target "LibWidget" + \(result: "-tr;ki18n"\): + + \* Target "LibWidget" property not set. + \* Target "KI18n" property value "-tr;ki18n" \(Interface set\) + \* Target "OtherI18n" property value "-tr;otheri18n" \(Disagree\) diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic.cmake b/Tests/RunCMake/CompatibleInterface/AutoUic.cmake new file mode 100644 index 0000000..86bd5a0 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/AutoUic.cmake @@ -0,0 +1,22 @@ + +find_package(Qt4 REQUIRED) + +set(QT_CORE_TARGET Qt4::QtCore) +set(QT_GUI_TARGET Qt4::QtGui) + +set(CMAKE_AUTOUIC ON) + +set(CMAKE_DEBUG_TARGET_PROPERTIES AUTOUIC_OPTIONS) + +add_library(KI18n INTERFACE) +set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS -tr ki18n +) + +add_library(OtherI18n INTERFACE) +set_property(TARGET OtherI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS -tr otheri18n +) + +add_library(LibWidget empty.cpp) +target_link_libraries(LibWidget KI18n OtherI18n ${QT_GUI_TARGET}) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake index ff2fe8d..b87adc8 100644 --- a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -10,3 +10,8 @@ run_cmake(InterfaceString-mismatched-use) run_cmake(InterfaceString-builtin-prop) run_cmake(InterfaceString-Bool-Conflict) run_cmake(DebugProperties) + +if (QT_QMAKE_EXECUTABLE}) + set(RunCMake_TEST_OPTIONS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) + run_cmake(AutoUic) +endif() diff --git a/Tests/RunCMake/CompatibleInterface/empty.cpp b/Tests/RunCMake/CompatibleInterface/empty.cpp new file mode 100644 index 0000000..0032329 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/empty.cpp @@ -0,0 +1 @@ +// no content -- cgit v0.12