[CMake] using Qt 4 resources with cmake and RCC ?

Clinton Stimpson clinton at elemtech.com
Mon Mar 27 11:07:54 EST 2006


>From: "dwikler at skynet.be" <dwikler at skynet.be>
>Subject: [CMake] using Qt 4 resources with cmake and RCC ?
>
>Dear All,
>
>I am a newbie to Qt 4 and I try to use CMake instead of qmake because I 
>also use ITK. I was not able to get RCC working with CMake though I have 
>seen in the FindQt4.cmake that it is supported.
>I added QT4_ADD_RESOURCES in my CMakeLists.txt but the .qrc file is not
>processed by RCC, and I get the following error at link:
>
>main.cxx:(.text+0x1e): undefined reference to `qInitResources_application()'
>
>related to the  Q_INIT_RESOURCE(application); line I added in my 
>main.cxx file as  described in the Qt documentation.
>
>Does somebody know how to do ?
>
>Thank you all.
>
>David
>
>Here is my CMakeLists.txt: (I am using CMake 2.2 Patch 2)
>
>PROJECT( QtApp )
>
>INCLUDE (${CMAKE_ROOT}/Modules/FindITK.cmake)
>IF ( USE_ITK_FILE )
>         INCLUDE(${USE_ITK_FILE})
>ENDIF( USE_ITK_FILE )
>
>INCLUDE (  ${CMAKE_ROOT}/Modules/FindQt.cmake  )
>
>INCLUDE(   ${QT_USE_FILE}   )
>
>SET(QtApp_SRCS main.cxx mainwindow.cxx)
>SET(QtApp_MOC_SRCS mainwindow.h)
>SET(QtApp_RCC_SRCS application.qrc)
>
>QT4_ADD_RESOURCES(application ${QtApp_RCC_SRCS})
>
>QT_WRAP_CPP(QtApp QtApp_SRCS ${QtApp_MOC_SRCS})
>
>ADD_EXECUTABLE(  QtApp ${QtApp_SRCS})
>
>TARGET_LINK_LIBRARIES ( QtApp ${QT_LIBRARIES}  )
>
> 
>David Wikler
>ULB
>Brussels, Belgium
>
>  
>
It should be something more like this...

PROJECT( QtApp )

INCLUDE (  ${CMAKE_ROOT}/Modules/FindQt4.cmake  )
INCLUDE(   ${QT_USE_FILE}   )

SET(QtApp_SRCS main.cxx mainwindow.cxx)
SET(QtApp_MOCS mainwindow.h)
SET(QtApp_RCCS application.qrc)

# generate rules for building source files from the resources
QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS})
# generate rules for building source files that moc generates
QT4_WRAP_CPP(QtApp_MOC_SRCS ${QtApp_MOCS})

# build sources, moc'd sources, and rcc'd sources
ADD_EXECUTABLE(  QtApp ${QtApp_SRCS} ${QtApp_MOC_SRCS} ${QtApp_RCC_SRCS})

TARGET_LINK_LIBRARIES ( QtApp ${QT_LIBRARIES}  )


Clint



More information about the CMake mailing list