FYI: watch out for Q_GADGET with cmake2.8
Harald Sitter
sitter at kde.org
Thu Dec 4 13:03:57 UTC 2014
alohas
Qt has a magic macro Q_GADGET which according to a websearch falls
slightly short of magic. It apparently allows non-QObject classes to
grow a metaobject such that one can use properties/enums/invokables.
Now the problem with that is that Q_GADGET is not supported by the
cmake2.8 automoc code, but cmake3 supports it.
This means cmake2.8 won't run automatically run moc which means the
metaglue is not generated which means that a library built with cmake3
potentially has more symbols (the ones for metaobject) on an exported
class than the exactly same source built with cmake2.8. Not good.
A quick grep suggested that only libnm-qt was actually affected by this.
But for future reference I'd like to point out that to use Q_GADGET
one either needs to bump the cmake requirement to >=3 OR better yet
explicitly include the moc'd cpp which will force cmake to run moc on
the header and thus makes it work with cmake2.8
e.g. in foo.cpp at the end #include "moc_foo.cpp"
(also, FWIW, all cases of Q_GADGET I looked at didn't actually need
it... perhaps if you have a defunct Q_GADGET floating about in a
private lib or application you should remove it ;))
HS
More information about the Kde-frameworks-devel
mailing list