Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.7.0
-
None
-
Qt 5.7.0 Windows 10 x64, Linux, OSX
-
17519feadd7309e125cc64bbac83f73b758c6a60
Description
Our project automatically generates missing .ts files, their corresponding .qm files, and then compiles those .qm files into the target binaries. This process has worked smoothly (only generating warnings during the qmake step) for several versions of Qt up until the most recent.
Here is some of the output during the qmake step (which is even generated with previous Qt versions):
RCC: Error in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc': Cannot find file 'Assets/Qt Messages/MyApplication_de_DE.qm' RCC: Error in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc': Cannot find file 'Assets/Qt Messages/MyApplication_en_US.qm' RCC: Error in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc': Cannot find file 'Assets/Qt Messages/MyApplication_es_ES.qm' RCC: Error in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc': Cannot find file 'Assets/Qt Messages/MyApplication_fr_FR.qm' RCC: Error in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc': Cannot find file 'Assets/Qt Messages/MyApplication_uk_UA.qm' RCC: Warning: No resources in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc'.
(The .ts and .qm files are generated within the source tree (not the shadow build directory))
During the build step, the .ts and .qm files are all generated prior to the resource files as intended.
However, with 5.7 the dependencies placed on the resources appear to be ignored/discarded, and, during the build step, the resources are attempted to be built first (before the dependent translation files are generated). As such, we see the following:
"C:\Program Files (x86)\Qt\5.7\msvc2015_64\bin\rcc.exe" -name MyApplication ...\ProjectSuite\Applications\MyApplication\MyApplication.qrc -o debug\rcc\qrc_MyApplication.cpp
RCC: Error in '...\ProjectSuite\Applications\MyApplication\MyApplication.qrc': Cannot find file 'Assets/Qt Messages/MyApplication_de_DE.qm'
jom: ...\build-ProjectSuite-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\Applications\MyApplication\Makefile [debug\rcc\qrc_MyApplication.cpp] Error 1
Here is a simplified version of the qmake code leveraged to handle this process (which works in 5.6.1 and below, but no longer works in 5.7.0):
SUPPORTED_LOCALES = en_US fr_FR es_ES de_DE uk_UA !isEmpty(SUPPORTED_LOCALES) { # Define output directories for .ts and .qm translation files TS_DIR = $$quote($${_PRO_FILE_PWD_}/Source/Translation Sources) QM_DIR = $$quote($${_PRO_FILE_PWD_}/Assets/Qt Messages) # Create translation file directories if missing !exists($$TS_DIR): mkpath($$TS_DIR) !exists($$QM_DIR): mkpath($$QM_DIR) LANGUAGE_FILE_ROOT_NAME = $${TARGET} TS_FILES QM_FILES for(supported_language, SUPPORTED_LOCALES) { LANGUAGE_FILE_BASE_NAME = $${LANGUAGE_FILE_ROOT_NAME}_$${supported_language} TS_FILES += \ $$quote($${TS_DIR}/$${LANGUAGE_FILE_BASE_NAME}.ts) QM_FILES += \ $$quote($${QM_DIR}/$${LANGUAGE_FILE_BASE_NAME}.qm) } TRANSLATIONS += $$TS_FILES ## Generate translation source files generate_ts_files.target = TSFiles generate_ts_files.depends = $$_PRO_FILE_ # FORCE generate_ts_files.CONFIG = no_link no_clean generate_ts_files.input = generate_ts_files.depends generate_ts_files.output = $$TS_FILES generate_ts_files.variable_out = PRE_TARGETDEPS win32: { generate_ts_files.commands = $(CHK_DIR_EXISTS) \"$$TS_DIR\" $(MKDIR) \"$$TS_DIR\" $$escape_expand(\n\t) lupdate $$_PRO_FILE_ } unix: { generate_ts_files.commands = $(CHK_DIR_EXISTS) \"$$TS_DIR\" || $(MKDIR) \"$$TS_DIR\" $$escape_expand(\n\t) lupdate $$_PRO_FILE_ } generate_ts_files.name = Generate $${LANGUAGE_FILE_ROOT_NAME} translation files QMAKE_EXTRA_TARGETS += generate_ts_files ## Generate Qt message files generate_qm_files.target = QMFiles generate_qm_files.depends = generate_ts_files # FORCE generate_qm_files.CONFIG = no_link no_clean recursive generate_qm_files.input = generate_qm_files.depends generate_qm_files.output = $$QM_FILES generate_qm_files.variable_out = PRE_TARGETDEPS win32: { generate_qm_files.commands = $(CHK_DIR_EXISTS) \"$$QM_DIR\" $(MKDIR) \"$$QM_DIR\" } unix: generate_qm_files.commands = $(CHK_DIR_EXISTS) \"$$QM_DIR\" || $(MKDIR) \"$$QM_DIR\" for(ts_file, generate_ts_files.output) { ts_file_base_name = $$basename(ts_file) qm_file_path = $${QM_DIR}/$$replace(ts_file_base_name, \.ts, .qm) generate_qm_files.commands += \ $$escape_expand(\n\t) $$LRELEASE \"$$ts_file\" -qm \"$$qm_file_path\" } generate_qm_files.name = Generate $${LANGUAGE_FILE_ROOT_NAME} Qt message files QMAKE_EXTRA_TARGETS += generate_qm_files # The object name rcc corresponds to the Makefile target compiler_rcc_make_all. rcc.depends += $$generate_qm_files.target }