[CMake] How to embed Qt resources using CMake

Pau Garcia i Quiles pgquiles at elpauer.org
Mon Jul 8 12:21:32 EDT 2013


Hello,

That's not how Qt4 resources are added with CMake. Here you have a good
explanation:

http://www.qtcentre.org/wiki/index.php?title=Compiling_Qt4_apps_with_CMake


On Mon, Jul 8, 2013 at 6:17 PM, Júlio Hoffimann
<julio.hoffimann at gmail.com>wrote:

> Dear all,
>
> I'm not that experienced with Qt, but I'm migrating an existing
> application to use CMake as the build system. It all worked smoothly,
> except the icons in the GUI aren't being shown.
>
> Suppose I'm a directory named main/ that has a subdirectory named
> resources/pixmaps:
>
> main/
> -- resources/
> -- -- pixmaps/
> -- -- -- icon1.png
> -- -- -- icon2.png
>
> My CMakeLists.txt resides at main/. I also have an icons.qrc with the
> following content:
>
> <RCC>
>     <qresource prefix="/icons">
>         <file>resources/pixmaps/icon1.png</file>
>         <file>resources/pixmaps/icon2.png</file>
>     </qresource></RCC>
>
>
> I tried the following:
>
> QT4_ADD_RESOURCES(lib_resources icons.qrc)
> add_library(mylib ${lib_srcs} ${lib_resources})
>
> Should I copy icons.qrc to the correspondent ${CMAKE_CURRENT_BINARY_DIR}?
> The paths in icons.qrc should be relative to what?
>
> I have tried put @CMAKE_CURRENT_SOURCE_DIR@ in the icons.qrc entries and
> configure_file() it for getting absolute paths:
>
> <RCC>
>     <qresource prefix="/icons">
>         <file alias="resources/pixmaps/icon1.png">@CMAKE_CURRENT_SOURCE_DIR@/resources/pixmaps/icon1.png</file>
>         <file alias="resources/pixmaps/icon2.png">@CMAKE_CURRENT_SOURCE_DIR@/resources/pixmaps/icon2.png</file>
>     </qresource></RCC>
>
>
> but also didn't work.
>
> I appreciate if you provide a minimal working example with best practices
> regarding CMake parallel builds. Perhaps a hello world example with an icon
> instead?
>
> Best,
> Júlio.
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130708/837158bc/attachment.htm>


More information about the CMake mailing list