From 6e2f4029c0e850a7420fba2ab953c0b6323e13fb Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 3 Sep 2021 09:36:40 -0400 Subject: cmAlgorithms: Preserve const-ness in cmRemoveDuplicates range signature The pattern `vec.erase(cmRemoveDuplicates(vec), vec.end())` fails to compile with GCC 4.8's libstdc++ if `cmRemoveDuplicates` returns a `const_iterator` because `end()` returns an `iterator`. Overload `cmRemoveDuplicates` to return an iterator type matching the const-ness of its argument. --- Source/cmAlgorithms.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index c192e2a..e0ba83d 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -133,7 +133,13 @@ ForwardIterator cmRemoveDuplicates(ForwardIterator first, ForwardIterator last) } template -typename Range::const_iterator cmRemoveDuplicates(Range& r) +typename Range::iterator cmRemoveDuplicates(Range& r) +{ + return cmRemoveDuplicates(r.begin(), r.end()); +} + +template +typename Range::const_iterator cmRemoveDuplicates(Range const& r) { return cmRemoveDuplicates(r.begin(), r.end()); } -- cgit v0.12 From 8ff0c2b1dd4b74a1e8e7a79adbfc5db55edff393 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Wed, 18 Aug 2021 13:28:01 +0200 Subject: AutoMoc: Do not list moc macros multiple times When working on a project with a nested dependency tree, a macro can be added multiple times. For example in a project I am working on, in the warning "includes the moc file [... ] but does not contain a [...] macro" the macro list contains 127 entries but only 25 unique ones. --- Source/cmQtAutoGenInitializer.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 6cc8328..c7d38bb 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -24,6 +24,7 @@ #include "cmsys/SystemInformation.hxx" +#include "cmAlgorithms.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmGeneratedFileStream.h" @@ -522,6 +523,8 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Filters cmExpandList(this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES"), this->Moc.MacroNames); + this->Moc.MacroNames.erase(cmRemoveDuplicates(this->Moc.MacroNames), + this->Moc.MacroNames.end()); { auto filterList = cmExpandedList( this->GenTarget->GetSafeProperty("AUTOMOC_DEPEND_FILTERS")); -- cgit v0.12