I have a Qt project with a german translation, Translation_de.ts
, which is automatically compiled into Translation_de.qm
via Qmake:
TRANSLATIONS += Translation_de.ts
...
QMAKE_EXTRA_COMPILERS += lrelease
lrelease.input = TRANSLATIONS
lrelease.output = ${QMAKE_FILE_BASE}.qm
lrelease.commands = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_BASE}.qm
lrelease.CONFIG += no_link target_predeps
The generated Translation_de.qm
is then compiled into the final application as a resource:
RESOURCES += Resources.qrc
where Resources.qrc
looks like this:
<RCC>
<qresource>
...
<file>Translation_de.qm</file>
</qresource>
</RCC>
All of this works fine, except that the very first call to Qmake on a fresh checkout throws the following annoying warning:
RCC: Error in 'Resources.qrc': Cannot find file 'Translation_de.qm'
What am I doing wrong here? How do I correctly specify an auto-generated resource file like Translation_de.qm
?
Create the generated files in qmake phase with e.g. system(lrelease...)
. Leave the other rules in place too so you don't have to rerun qmake when the input files are changed.