[CMake] QT4_ADD_RESOURCES not creating cpp on Mac OS X

Nick Arini n.arini at btinternet.com
Mon Oct 23 15:15:30 EDT 2006


Dear CMake users,

I am trying to get some resources (icon images) compiled in a Qt  
application on Mac OS X (10.4.8 Tiger) with cmake 2.4-patch 3.

I am using version 4.2.0-snapshot-20060910 of Qt.

I have the following in my CMakeLists.txt:

PROJECT(QtApp)


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

INCLUDE_DIRECTORIES(
${QT_INCLUDE_DIR}
${QT_QTGUI_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${QT_INCLUDE_PATH}
)

LINK_LIBRARIES (
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
)


# Gather the source files
SET(QtApp_SRCS
main.cpp
)


#SET(QtApp_MOCS
#)

SET(QtApp_RCCS
icons.qrc
)

# generate rules for building source files from the resources
QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS})

#QT4_WRAP_CPP(QtApp_MOC_SRCS ${VTKD_MOCS})

# Create the executable
ADD_EXECUTABLE(QtApp ${QtApp_SRCS} ${QtApp_RCCS_SRCS})

# Link in the appropriate libraries
TARGET_LINK_LIBRARIES(
QtApp ${QT_LIBRARIES}
)

I have a resource file called icons.qrc in my cmake source dir:

<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
     <file>images/stock_exit-16.png</file>
     <file>images/stock_new-16.png</file>
     <file>images/stock_save-16.png</file>
     <file>images/stock_stop-16.png</file>
     <file>images/stock_zoom-in-16.png</file>
     <file>images/stock_exit.png</file>
     <file>images/stock_new-document-32.png</file>
     <file>images/stock_save.png</file>
     <file>images/stock_stop.png</file>
     <file>images/stock_zoom-in.png</file>
     <file>images/stock_help-16.png</file>
     <file>images/stock_open-16.png</file>
     <file>images/stock_save_as-16.png</file>
     <file>images/stock_sum-16.png</file>
     <file>images/stock_zoom-out-16.png</file>
     <file>images/stock_help.png</file>
     <file>images/stock_open.png</file>
     <file>images/stock_save_as.png</file>
     <file>images/stock_sum.png</file>
     <file>images/stock_zoom-out.png</file>
</qresource>

When I run CMake I expect the file qrc_icons.cpp to be created in the  
build directory.

The main.cpp is as follows:

#include <QApplication>
#include <QLabel>
#include <QIcon>

int main(int argc, char *argv[])
{
   QApplication app(argc, argv);
   app.setWindowIcon ( QIcon(":/images/stock_sum.png") );

   QLabel *window = new QLabel("Test");
   window->setPixmap ( QPixmap(":/images/stock_sum.png") );
   window->show();

   return app.exec();
}

the images themselves are in a dir called images in the CMake source  
dir.

Cmake will run fine and the code will compile and execute ok, just  
not with the images as RCC does not seem to run and the qrc_icons.o  
file isnt created.

I tried the very same code (no changes) on Fedora Core 5 with Qt  
version 4.2.1 and CMake version 2.4 patch 3 and everything worked as  
expected (the qrc_icons.o file is created) and the exe runs with the  
images.

So is this a problem with the FindQt4 module on MacOS X or do I need  
to do something extra on Mac? I have the RCC exe in my path and it  
produces the expected output when I run it manually.


Thanks and best regards,

Nick





More information about the CMake mailing list