Fix wrong automoc warnings: "includes moc file, but contains no macro x, y, z."
Closed, ResolvedPublic

Description

Currently with Qt6 and building against KF6 one gets a lot of warnings like

AutoMoc warning
---------------
"BIN:/src/dbus/maininterface.cpp"
includes the moc file "maininterface.moc", but does not contain a Q_OBJECT, Q_GADGET, Q_GADGET_EXPORT, Q_NAMESPACE or Q_NAMESPACE_EXPORT macro.

when actually one uses one of the KF macros which needs moc to be run onto the file.

So far KF modules have been using ECMSetupQtPluginMacroNames to e.g. prepare the installed CMake config files to setup CMAKE_AUTOMOC_MACRO_NAMES with any additional macros provided in the own public interface. Avoiding any consumers to have to set up things themselves.

With Qt6 this is broken, as right now (Qt 6.4.2) any time find_package(Qt6Core CONFIG REQUIRED)
or find_dependency(Qt6Core) is executed, CMAKE_AUTOMOC_MACRO_NAMES is reset. With Qt5 this only happened the first time (guarded by presence of target Qt5::Core).

Possibly best done by fixing in Qt6. Filed as https://bugreports.qt.io/browse/QTBUG-110497

kossebau created this task.Jan 23 2023, 3:30 PM
alex claimed this task.May 8 2023, 2:38 PM
alex closed this task as Resolved.
alex added a subscriber: alex.

This is fixed upstream!