Fix Qt resource handling
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 31 Mar 2014 19:58:27 +0000 (21:58 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 31 Mar 2014 20:05:01 +0000 (22:05 +0200)
Turns out we have to explicitly initialize Qt resources that are linked
statically, so our last build system change broke things because the
files where nowhere to be found.

This now initializes the resources in main(); additionally, we use absolute
paths for the qrc files now, simply for making things a bit clearer.

data/CMakeLists.txt
icons/CMakeLists.txt
pics/CMakeLists.txt
src/CMakeLists.txt
src/common/main.cpp
src/core/CMakeLists.txt

index c5e6c9b..e9f4a06 100644 (file)
@@ -14,7 +14,7 @@ if (BUILD_GUI)
     endif()
 
     if (EMBED_DATA)
-        set(CLIENT_RCS ${CLIENT_RCS} ../../data/data.qrc PARENT_SCOPE)
+        set(CLIENT_RCS ${CLIENT_RCS} ${CMAKE_CURRENT_SOURCE_DIR}/data.qrc PARENT_SCOPE)
     else()
         install(FILES networks.ini DESTINATION ${DATA_INSTALL_DIR}/quassel)
         install(DIRECTORY stylesheets DESTINATION ${DATA_INSTALL_DIR}/quassel)
index fe2273d..b9cc9a0 100644 (file)
@@ -25,9 +25,9 @@ if(WANT_MONO OR WANT_QTCLIENT)
   endif(INSTALL_OXY)
 
   if(EMBED_DATA)
-    set(ICON_RCS ../../icons/hicolor.qrc ../../icons/oxygen.qrc)
+    set(ICON_RCS ${CMAKE_CURRENT_SOURCE_DIR}/hicolor.qrc ${CMAKE_CURRENT_SOURCE_DIR}/oxygen.qrc)
     if(INSTALL_OXY)
-      set(ICON_RCS ${ICON_RCS} ../../icons/oxygen_kde.qrc)
+      set(ICON_RCS ${ICON_RCS} ${CMAKE_CURRENT_SOURCE_DIR}/oxygen_kde.qrc)
     endif(INSTALL_OXY)
     set(CLIENT_RCS ${CLIENT_RCS} ${ICON_RCS} PARENT_SCOPE)
   else(EMBED_DATA)
index 75f44aa..42da388 100644 (file)
@@ -11,16 +11,16 @@ if(WIN32)
       set(COMMON_DEPS ${COMMON_DEPS} ${CMAKE_CURRENT_BINARY_DIR}/win32.o PARENT_SCOPE)
     endif(WINDRES_EXECUTABLE)
   else(MINGW)
-    set(COMMON_DEPS ${COMMON_DEPS} ../../pics/win32.rc PARENT_SCOPE)
+    set(COMMON_DEPS ${COMMON_DEPS} ${CMAKE_CURRENT_SOURCE_DIR}/win32.rc PARENT_SCOPE)
   endif(MINGW)
 endif(WIN32)
 
 if(WANT_MONO OR WANT_QTCLIENT)
   if(EMBED_DATA)
-    set(CLIENT_RCS ${CLIENT_RCS} ../../pics/pics.qrc PARENT_SCOPE)
+    set(CLIENT_RCS ${CLIENT_RCS} ${CMAKE_CURRENT_SOURCE_DIR}/pics.qrc PARENT_SCOPE)
   else(EMBED_DATA)
     # We don't find them yet externally, so disable installation
-    set(CLIENT_RCS ${CLIENT_RCS} ../../pics/pics.qrc PARENT_SCOPE)
+    set(CLIENT_RCS ${CLIENT_RCS} ${CMAKE_CURRENT_SOURCE_DIR}/pics.qrc PARENT_SCOPE)
     # install(FILES qt-logo.png
     #               quassel-large.png
     #         DESTINATION ${DATA_INSTALL_DIR}/quassel/pics)
index 49052e1..4d431e4 100644 (file)
@@ -22,6 +22,13 @@ endif(BUILD_GUI)
 
 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) # for version.gen
 
+# We need to initialize the appropriate resources, so let's give our main.cpp some hints
+if (EMBED_DATA)
+    add_definitions(-DEMBED_DATA)
+endif()
+if (WITH_OXYGEN)
+    add_definitions(-DWITH_OXYGEN)
+endif()
 
 if(WANT_CORE)
   add_executable(quasselcore common/main.cpp)
index d381381..7884dfa 100644 (file)
@@ -62,6 +62,26 @@ int main(int argc, char **argv)
     QApplication::setGraphicsSystem("raster");
 #endif
 
+    // We need to explicitly initialize the required resources when linking statically
+#ifndef BUILD_QTUI
+    Q_INIT_RESOURCE(sql);
+#endif
+#ifndef BUILD_CORE
+    Q_INIT_RESOURCE(pics); // always in a resource, for now
+#endif
+
+#ifdef EMBED_DATA
+    Q_INIT_RESOURCE(i18n);
+# ifndef BUILD_CORE
+    Q_INIT_RESOURCE(data);
+    Q_INIT_RESOURCE(hicolor);
+    Q_INIT_RESOURCE(oxygen);
+#   ifdef WITH_OXYGEN
+    Q_INIT_RESOURCE(oxygen_kde);
+#   endif
+# endif
+#endif
+
     AbstractCliParser *cliParser;
 
 #ifdef HAVE_KDE
index deca428..6a0611a 100644 (file)
@@ -56,8 +56,7 @@ endif()
 
 include_directories(${CMAKE_SOURCE_DIR}/src/common)
 
-set(CORE_RCS ${CORE_RCS} core/sql.qrc PARENT_SCOPE)
-
+set(CORE_RCS ${CORE_RCS} ${CMAKE_CURRENT_SOURCE_DIR}/sql.qrc)
 qt_add_resources(SOURCES ${CORE_RCS})
 
 add_library(mod_core STATIC ${SOURCES})