cmake: fix Qt resources linkage. Closes #5080

Qt resource is innitialized by a static object constructor (see
https://wiki.qt.io/QtResources). When we put resources into a static
library, the linker removes that static objects and thus the resources
themselves. To correct that we append resources to the main executable
sources list. This is done via custom function qbt_target_sources which
knows where to read the executable' name.
This commit is contained in:
Eugene Shalygin
2016-04-17 00:55:45 +02:00
committed by sledgehammer999
parent fd156580a0
commit b137eb01ed
6 changed files with 38 additions and 11 deletions

View File

@@ -26,10 +26,11 @@ if (QT4_FOUND)
endif(NOT SYSTEM_QJSON)
endif (QT4_FOUND)
set(QBT_WEBUI_RESOURCES webui.qrc)
add_library(qbt_webui STATIC ${QBT_WEBUI_HEADERS} ${QBT_WEBUI_SOURCES} ${QBT_WEBUI_RESOURCES})
qbt_target_sources(webui.qrc)
add_library(qbt_webui STATIC ${QBT_WEBUI_HEADERS} ${QBT_WEBUI_SOURCES})
target_link_libraries(qbt_webui qbt_base)
if (QT4_FOUND)
target_link_libraries(qbt_webui qjson)
target_link_libraries(qbt_webui qjson)
endif (QT4_FOUND)