Avoid race conditions in the build system
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 28 Mar 2014 23:57:22 +0000 (00:57 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 28 Mar 2014 23:57:22 +0000 (00:57 +0100)
Adding resource files in multiple targets is a bad idea, because CMake
will happily generate them multiple times too, and unfortunately also
in the same location. With Qt5, this actually lead to a misgenerated
oxygen_kde.qrc some times.

Now we add the resources in the module they belong to, which not only
avoids these race conditions, but also saves some time during compile,
because every resource file is only processed once now.

Changing this triggered yet another race condition, where not all translations
would be generated by the time the corresponding .qrc was needed. Adding
a fugly add_dependencies(mod_common po) fixes this; however we may want to
find a cleaner way to properly express deps between the language files and the
qrc.

data/CMakeLists.txt
icons/CMakeLists.txt
pics/CMakeLists.txt
po/CMakeLists.txt
src/CMakeLists.txt
src/client/CMakeLists.txt
src/common/CMakeLists.txt
src/core/CMakeLists.txt

index e795e66..c5e6c9b 100644 (file)
@@ -14,7 +14,7 @@ if (BUILD_GUI)
     endif()
 
     if (EMBED_DATA)
     endif()
 
     if (EMBED_DATA)
-        set(CLIENT_RCS ${CLIENT_RCS} ../data/data.qrc PARENT_SCOPE)
+        set(CLIENT_RCS ${CLIENT_RCS} ../../data/data.qrc PARENT_SCOPE)
     else()
         install(FILES networks.ini DESTINATION ${DATA_INSTALL_DIR}/quassel)
         install(DIRECTORY stylesheets DESTINATION ${DATA_INSTALL_DIR}/quassel)
     else()
         install(FILES networks.ini DESTINATION ${DATA_INSTALL_DIR}/quassel)
         install(DIRECTORY stylesheets DESTINATION ${DATA_INSTALL_DIR}/quassel)
index 3eaea88..fe2273d 100644 (file)
@@ -25,9 +25,9 @@ if(WANT_MONO OR WANT_QTCLIENT)
   endif(INSTALL_OXY)
 
   if(EMBED_DATA)
   endif(INSTALL_OXY)
 
   if(EMBED_DATA)
-    set(ICON_RCS ../icons/hicolor.qrc ../icons/oxygen.qrc)
+    set(ICON_RCS ../../icons/hicolor.qrc ../../icons/oxygen.qrc)
     if(INSTALL_OXY)
     if(INSTALL_OXY)
-      set(ICON_RCS ${ICON_RCS} ../icons/oxygen_kde.qrc)
+      set(ICON_RCS ${ICON_RCS} ../../icons/oxygen_kde.qrc)
     endif(INSTALL_OXY)
     set(CLIENT_RCS ${CLIENT_RCS} ${ICON_RCS} PARENT_SCOPE)
   else(EMBED_DATA)
     endif(INSTALL_OXY)
     set(CLIENT_RCS ${CLIENT_RCS} ${ICON_RCS} PARENT_SCOPE)
   else(EMBED_DATA)
index 5eb47d6..75f44aa 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} ${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} ../../pics/win32.rc PARENT_SCOPE)
   endif(MINGW)
 endif(WIN32)
 
 if(WANT_MONO OR WANT_QTCLIENT)
   if(EMBED_DATA)
   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} ../../pics/pics.qrc PARENT_SCOPE)
   else(EMBED_DATA)
     # We don't find them yet externally, so disable installation
   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} ../../pics/pics.qrc PARENT_SCOPE)
     # install(FILES qt-logo.png
     #               quassel-large.png
     #         DESTINATION ${DATA_INSTALL_DIR}/quassel/pics)
     # install(FILES qt-logo.png
     #               quassel-large.png
     #         DESTINATION ${DATA_INSTALL_DIR}/quassel/pics)
index 6879f03..d1df92c 100644 (file)
@@ -68,3 +68,5 @@ else(EMBED_DATA)
 endif(EMBED_DATA)
 
 add_custom_target(po DEPENDS ${qm_files})
 endif(EMBED_DATA)
 
 add_custom_target(po DEPENDS ${qm_files})
+
+
index 3a88d28..49052e1 100644 (file)
@@ -22,14 +22,9 @@ endif(BUILD_GUI)
 
 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) # for version.gen
 
 
 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) # for version.gen
 
-# Add resources. Can't be done in other subdirs apparently.
-# Note that these variables need to contain paths relative to src/ (this dir)
-qt_add_resources(CLIENT_DEPS ${CLIENT_RCS})
-qt_add_resources(CORE_DEPS ${CORE_RCS})
-qt_add_resources(COMMON_DEPS ${COMMON_RCS})
 
 if(WANT_CORE)
 
 if(WANT_CORE)
-  add_executable(quasselcore common/main.cpp ${COMMON_DEPS} ${CORE_DEPS})
+  add_executable(quasselcore common/main.cpp)
   qt_use_modules(quasselcore Core Network ${CORE_QT_MODULES})
   add_dependencies(quasselcore po)
   set_target_properties(quasselcore PROPERTIES
   qt_use_modules(quasselcore Core Network ${CORE_QT_MODULES})
   add_dependencies(quasselcore po)
   set_target_properties(quasselcore PROPERTIES
@@ -44,7 +39,7 @@ if (KDE4_FOUND)
 endif()
 
 if(WANT_QTCLIENT)
 endif()
 
 if(WANT_QTCLIENT)
-  add_executable(quasselclient WIN32 common/main.cpp ${COMMON_DEPS} ${CLIENT_DEPS})
+  add_executable(quasselclient WIN32 common/main.cpp)
   qt_use_modules(quasselclient Core Gui Network ${CLIENT_QT_MODULES})
   add_dependencies(quasselclient po)
   set_target_properties(quasselclient PROPERTIES
   qt_use_modules(quasselclient Core Gui Network ${CLIENT_QT_MODULES})
   add_dependencies(quasselclient po)
   set_target_properties(quasselclient PROPERTIES
@@ -55,7 +50,7 @@ if(WANT_QTCLIENT)
 endif(WANT_QTCLIENT)
 
 if(WANT_MONO)
 endif(WANT_QTCLIENT)
 
 if(WANT_MONO)
-  add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS})
+  add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp)
   qt_use_modules(quassel Core Gui Network ${CLIENT_QT_MODULES} ${CORE_QT_MODULES})
   add_dependencies(quassel po)
   set_target_properties(quassel PROPERTIES
   qt_use_modules(quassel Core Gui Network ${CLIENT_QT_MODULES} ${CORE_QT_MODULES})
   add_dependencies(quassel po)
   set_target_properties(quassel PROPERTIES
index bc74ecc..3dd1504 100644 (file)
@@ -47,6 +47,8 @@ if (USE_QT5)
     list(APPEND qt_modules Widgets)
 endif()
 
     list(APPEND qt_modules Widgets)
 endif()
 
+qt_add_resources(SOURCES ${CLIENT_RCS})
+
 add_library(mod_client STATIC ${SOURCES})
 qt_use_modules(mod_client Network Core Gui ${qt_modules})
 
 add_library(mod_client STATIC ${SOURCES})
 qt_use_modules(mod_client Network Core Gui ${qt_modules})
 
index 101498c..23e5601 100644 (file)
@@ -76,6 +76,8 @@ else()
     set(SOURCES ${SOURCES} logbacktrace_unix.cpp)
 endif()
 
     set(SOURCES ${SOURCES} logbacktrace_unix.cpp)
 endif()
 
+qt_add_resources(SOURCES ${COMMON_RCS})
+
 add_library(mod_common STATIC ${SOURCES})
 qt_use_modules(mod_common Core Network)
 
 add_library(mod_common STATIC ${SOURCES})
 qt_use_modules(mod_common Core Network)
 
@@ -84,3 +86,7 @@ if(APPLE)
 endif(APPLE)
 
 target_link_libraries(mod_common ${CMAKE_DL_LIBS} ${EXECINFO_LIBRARIES} ${ZLIB_LIBRARIES})
 endif(APPLE)
 
 target_link_libraries(mod_common ${CMAKE_DL_LIBS} ${EXECINFO_LIBRARIES} ${ZLIB_LIBRARIES})
+
+# This is needed so translations are generated before trying to build the qrc.
+# Should probably find a nicer solution with proper dependencies between the involved files, though...
+add_dependencies(mod_common po)
index e337235..deca428 100644 (file)
@@ -58,6 +58,8 @@ include_directories(${CMAKE_SOURCE_DIR}/src/common)
 
 set(CORE_RCS ${CORE_RCS} core/sql.qrc PARENT_SCOPE)
 
 
 set(CORE_RCS ${CORE_RCS} core/sql.qrc PARENT_SCOPE)
 
+qt_add_resources(SOURCES ${CORE_RCS})
+
 add_library(mod_core STATIC ${SOURCES})
 qt_use_modules(mod_core Core Network Script Sql)
 
 add_library(mod_core STATIC ${SOURCES})
 qt_use_modules(mod_core Core Network Script Sql)