From 9e21879f361dfe9978fb5159664cae352301064b Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sat, 29 Mar 2014 00:57:22 +0100 Subject: [PATCH] Avoid race conditions in the build system 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 | 2 +- icons/CMakeLists.txt | 4 ++-- pics/CMakeLists.txt | 6 +++--- po/CMakeLists.txt | 2 ++ src/CMakeLists.txt | 11 +++-------- src/client/CMakeLists.txt | 2 ++ src/common/CMakeLists.txt | 6 ++++++ src/core/CMakeLists.txt | 2 ++ 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index e795e66b..c5e6c9b6 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -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} ../../data/data.qrc PARENT_SCOPE) else() install(FILES networks.ini DESTINATION ${DATA_INSTALL_DIR}/quassel) install(DIRECTORY stylesheets DESTINATION ${DATA_INSTALL_DIR}/quassel) diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 3eaea88a..fe2273d4 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -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 ../../icons/hicolor.qrc ../../icons/oxygen.qrc) 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) diff --git a/pics/CMakeLists.txt b/pics/CMakeLists.txt index 5eb47d64..75f44aae 100644 --- a/pics/CMakeLists.txt +++ b/pics/CMakeLists.txt @@ -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} ../../pics/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} ../../pics/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} ../../pics/pics.qrc PARENT_SCOPE) # install(FILES qt-logo.png # quassel-large.png # DESTINATION ${DATA_INSTALL_DIR}/quassel/pics) diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 6879f03f..d1df92c7 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -68,3 +68,5 @@ else(EMBED_DATA) endif(EMBED_DATA) add_custom_target(po DEPENDS ${qm_files}) + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a88d281..49052e14 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,14 +22,9 @@ endif(BUILD_GUI) 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) - 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 @@ -44,7 +39,7 @@ if (KDE4_FOUND) 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 @@ -55,7 +50,7 @@ if(WANT_QTCLIENT) 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 diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index bc74ecce..3dd15044 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -47,6 +47,8 @@ if (USE_QT5) 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}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 101498c8..23e5601e 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -76,6 +76,8 @@ else() 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) @@ -84,3 +86,7 @@ if(APPLE) 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) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e3372355..deca4286 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -58,6 +58,8 @@ include_directories(${CMAKE_SOURCE_DIR}/src/common) 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) -- 2.20.1