[Qt-interest] cmake: ui library?

Rui Maciel rui.maciel at gmail.com
Tue Feb 14 02:59:22 CET 2012


Stefan Majewsky wrote:

> On Mon, Feb 13, 2012 at 10:16 PM, Rui Maciel <rui.maciel at gmail.com> wrote:
>> Then, I proceeded to pass libui to the TARGET_LINK_LIBRARIES() command
>> and add ${libui_HEADERS} to the projec_HEADERS list.
>>
>> Yet, when I try to compile the project, the compiler throws a series of
>> errors about "undefined reference to `vtable for <ui class name here>'".
> 
> Looks like the moc files are missing in your picture. Since you're
> probably just starting, you should read about the automoc
> functionality which was recently introduced into CMake. A long
> introduction is at http://blogs.kde.org/node/4495 but in your case,
> the quick answer should be
> 
> set(CMAKE_AUTOMOC TRUE)
> 
> Probably before add_library(). Have not tried it though, see the
> linked article for details.

I've followed your suggestion but unfortunately it doesn't work.


>> So, does anyone know how to setup cmake to churn out a static library
>> from Qt code?
> 
> add_library(foobar STATIC ${foobar_SOURCES})

It appears that, if a project uses uic and moc-generated source files, the 
add_library() macro also needs the output of QT4_WRAP_CPP() and 
QT4_WRAP_UI().  So, it's more like the following:

add_library(ui STATIC ${ui_SOURCES} ${ui_HEADERS_MOC} ${ui_FORMS_HEADERS} )


> P.S. Remember to change your subscription to the new list at
> interest at qt-project.org.

I'm following this mailing list through nokia's nntp server.


Rui Maciel



More information about the Qt-interest-old mailing list