I have changed the project file to make sure SOURCES always contains the generated files:
test.pro:
SOURCES = main.cpp
TRANSLATIONS=test_de.ts
GEN_SOURCES = generated.cpp
include( gen.pri )
SOURCES = main.cpp
TRANSLATIONS=test_de.ts
GEN_SOURCES = generated.cpp
include( gen.pri )
To copy to clipboard, switch view to plain text mode
gen.pri:
SOURCES += $$GEN_SOURCES
for( src, GEN_SOURCES ): GEN_INPUT += $$replace( src, .cpp, .gen )
gen.input = GEN_INPUT
gen.output = ${QMAKE_FILE_BASE}.cpp
gen.commands = cp ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
gen.variable_out =
QMAKE_EXTRA_COMPILERS += gen
SOURCES += $$GEN_SOURCES
for( src, GEN_SOURCES ): GEN_INPUT += $$replace( src, .cpp, .gen )
gen.input = GEN_INPUT
gen.output = ${QMAKE_FILE_BASE}.cpp
gen.commands = cp ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
gen.variable_out =
QMAKE_EXTRA_COMPILERS += gen
To copy to clipboard, switch view to plain text mode
Now when I invoke "lupdate test.pro" after the project was built, it works fine.
The remaining problem is that it will fail silently if the project was not built and "generated.cpp" does not exist (not even a warning)!
This is a problem to me since I might accidentally damage my translation files without even noticing if I forget to build the project before calling lupdate...
Bookmarks