[cmake-developers] cmake automoc breaks kde

Alexander Neundorf neundorf at kde.org
Fri Dec 2 16:11:28 EST 2011


On Friday 02 December 2011, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> >> You said that you can't detect this case, but why do you have to? Isn't
> >> there already a check for the Q_OBJECT macro in the cpp file? Wouldn't
> >> the logic be 'if the <basename>.moc file is included but there is no
> >> Q_OBJECT in the header, then moc the <basename>.h and put the result in
> >> <basename>.moc', or does that conflict with another rule?
> > 
> > I'll put some more work in it over the weekend.
> > Probably something like this should work.
> > Or "if it's not my own .moc-file, never assume it's the .moc-file from
> > another cpp-file (end of story here with Qt5), but try whether it could
> > be the moc- file from a header".
> 
> Please make the behaviour difference not determined by Qt4 vs Qt5 but by a
> variable.
> 
> That is, please make:
> 
> find_package(Qt4)
> set(CMAKE_AUTOMOC ON)
> set(CMAKE_AUTOMOC_STRICT ON)
> 
> behave with what you call the 'Qt5' behaviour, and
> 
> find_package(QtCore 5)
> set(CMAKE_AUTOMOC ON)
> set(CMAKE_AUTOMOC_STRICT OFF)
> 
> behave with what you call the 'Qt4' behaviour.
> 
> That is, introduce a CMAKE_AUTOMOC_STRICT variable to control which mode
> the automoc stuff works with, and have a different default between Qt4 and
> Qt5, but allow overriding that default.
> 
> Porting to Qt5 (for KDE at least) needs to eb a multi-step process for
> applications depending on kdelibs (and this feature). I think it needs to
> be possible to run automoc in non-strict mode with Qt5.

Please try the current AutomocIncludedDotMocFileHandling branch.
It now accepts even more included .moc files.
It also builds solid as it is, but you get a whole lot of warnings.

Without commit 40c516783e1df141f3d4a8 solid doesn't build, it fails with the 
included AudioDevice.moc file, but this patch also causes the many warnings 
mentioned above.

The switch variable is called CMAKE_AUTOMOC_STRICT_MODE.

Docs and a test are still missing.

Alex



More information about the cmake-developers mailing list