<div dir="ltr">Dear all,<div><br></div><div>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.</div>
<div><br></div><div>Suppose I'm a directory named main/ that has a subdirectory named resources/pixmaps:</div><div><br></div><div>main/</div><div>-- resources/</div><div>-- -- pixmaps/</div><div>-- -- -- icon1.png</div>
<div>-- -- -- icon2.png</div><div><br></div><div>My CMakeLists.txt resides at main/. I also have an icons.qrc with the following content:</div><div><pre style="color:rgb(0,0,0);font-size:medium"><span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">RCC</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">qresource</span> <span style="color:rgb(39,71,150)">prefix</span><span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(0,0,230)">/icons</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">file</span><span style="color:rgb(166,87,0)">></span>resources/pixmaps/icon1.png<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">file</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">file</span><span style="color:rgb(166,87,0)">></span>resources/pixmaps/icon2.png<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">file</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">qresource</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">RCC</span><span style="color:rgb(166,87,0)">></span></pre></div><div><br></div><div>I tried the following:</div><div><br></div><div>QT4_ADD_RESOURCES(lib_resources icons.qrc)</div>
<div>add_library(mylib ${lib_srcs} ${lib_resources})</div><div><br></div><div>Should I copy icons.qrc to the correspondent ${CMAKE_CURRENT_BINARY_DIR}? The paths in icons.qrc should be relative to what?</div><div><br></div>
<div>I have tried put @CMAKE_CURRENT_SOURCE_DIR@ in the icons.qrc entries and configure_file() it for getting absolute paths:</div><div><br></div><div><pre style="color:rgb(0,0,0);font-size:medium"><span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">RCC</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">qresource</span> <span style="color:rgb(39,71,150)">prefix</span><span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(0,0,230)">/icons</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">file</span> <span style="color:rgb(39,71,150)">alias</span><span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(0,0,230)">resources/pixmaps/icon1.png</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(166,87,0)">></span>@CMAKE_CURRENT_SOURCE_DIR@/resources/pixmaps/icon1.png<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">file</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"><</span><span style="color:rgb(95,80,53)">file</span> <span style="color:rgb(39,71,150)">alias</span><span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(0,0,230)">resources/pixmaps/icon2.png</span><span style="color:rgb(0,0,230)">"</span><span style="color:rgb(166,87,0)">></span>@CMAKE_CURRENT_SOURCE_DIR@/resources/pixmaps/icon2.png<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">file</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">qresource</span><span style="color:rgb(166,87,0)">></span>
<span style="color:rgb(166,87,0)"></</span><span style="color:rgb(95,80,53)">RCC</span><span style="color:rgb(166,87,0)">></span></pre></div><div><br></div><div>but also didn't work.</div><div><br></div><div>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?</div>
<div><br></div><div>Best,</div><div>Júlio.</div></div>