This forum has been archived. All content is frozen. Please use KDE Discuss instead.

CMake and kde_add_ui_files problem

Tags: None
(comma "," separated)
pegasus87
Registered Member
Posts
1
Karma
0
OS

CMake and kde_add_ui_files problem

Wed Oct 05, 2011 9:54 pm
Hi,

I just started to write my first KDE program und read some tutorials on techbase.
My first practise was to use the KXmlGuiWindow class and the *.rc files for building my UI. But now I created a *.ui file with the Qt Designer. So I just followed the tutorial and added this line to my CMakeList.txt
Code: Select all
kde4_add_ui_files(testSRC src/mainwidget.ui)

Now my CMakeList.txt looks like this:
Code: Select all
project(kde_test)

find_package(KDE4 REQUIRED)
include (KDE4Defaults)

include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} )

#add_subdirectory( doc )
#add_subdirectory( src )

set(testSRC
    src/main.cpp
    src/mainwindow.cpp
)

kde4_add_ui_files(testSRC src/mainwidget.ui)

kde4_add_executable(kde_test ${testSRC})


target_link_libraries(kde_test ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})

install(TARGETS kde_test ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES src/testui.rc
        DESTINATION  ${DATA_INSTALL_DIR}/test)

Pretty simple I think.
Now my problem:
If I add
Code: Select all
#include "src/ui_mainwidget.h"

to my source files, I get a "no such file or directory" error message, because ui_mainwidget.h was not generated. I don't now why CMake doesn't call uic to generate it. I get the generated code if I run uic manually.

Do I have to add more lines to CMakeList.txt?

Thank you for help!
Musikolo
Registered Member
Posts
27
Karma
0
OS
Hi Pegasus87,

I don't know if it'll be much helpful for you, but I think you have to add the following line below kde4_add_ui_files(testSRC src/mainwidget.ui), like this:
Code: Select all
kde4_add_ui_files(${testSRC} src/mainwidget.ui)
qt4_automoc(${testSRC})

Besides, I think you have to put testSRC between ${}, because otherwise it won't be understood as a variable. You can use the one I have to build KVirusTotal as a nice example: https://gitorious.org/kvirustotal/kvirustotal/blobs/master/CMakeLists.txt

I hope it helps! ;)


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]