Qt5 CMake AUTOMOC "bug" and Widget Collections (duplicate plugin symbols) [solved]



  • I've been puzzled for a couple of days while trying to port a custom widget consisting of two basic sub widgets to Qt5. I am using CMake as the building system and I discovered a subtle AUTOMOC bug in case of widget collections.

    In my case I had two basic widget plugins plus another plugin that combined both in a single interface to be exposed in a widget collection library.

    @
    class SchedulingWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {};

    class RoutingWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {};

    class CombinedWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {};
    @

    and the overall widget collection:

    @
    class SRViewers : public QObject, public QDesignerCustomWidgetCollectionInterface {};
    @

    and all these files (plus all the other dependencies) were compiled with the following CMake rules, where ${srviewersplugin_SOURCES} included all the sources and ${srviewersplugin_HEADERS} all the headers (to be automocced) as follows:

    @
    add_library(srviewersplugin ${srviewersplugin_SOURCES} ${srviewersplugin_FORMS_HEADERS} ${srviewersplugin_HEADERS} ${srviewersplugin_RESOURCES_RCC})
    target_link_libraries(srviewersplugin ${Boost_LIBRARIES} Qt5::Widgets Qt5::Designer Qt5::WebKit Qt5::WebKitWidgets Qt5::Core Qt5::Gui)
    @

    In Qt5, AUTOMOC seems to call moc on each of the three basic widget plugins in isolation, resulting in duplicate plugin symbols:
    @Redefinition of 'qt_section_alignment_dummy'@
    plus a bunch of other symbols). The only option for me to switch off AUTOMOC and to use a qt5_wrap_cpp() cmake rule so to avoid duplicate symbols.

    Hope this will be helpful to someone else

    Cheers,

    Luca


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.