qmsetup
qmsetup copied to clipboard
In qm_add_translation, the .ts file is not updated automatically
In file Translate.cmake, line 275
add_custom_command(
TARGET ${_target}
COMMAND ${_lupdate_exe}
ARGS ${_LUPDATE_OPTIONS} "@${_ts_lst_file}" -ts ${_ts_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${_my_sources}
BYPRODUCTS ${_ts_lst_file}
VERBATIM
)
This code doesn't work, unable to update the ts file.
add_custom_command instructions are executed in the build phase, which is not very friendly to development, can it be generated in the cmake phase.
Or control whether an update is required through a variable.Because this step may be time -consuming.
It seems that you are not completely aware of how the translation function works. We cannot update the ts
files at configure phase because source files cannot be modified during configure phase while ts
files are also a kind of source file. You can set the target name when calling qm_add_translation(xxx ...)
and a target named xxx_lupdate
will be created. After configure phase, you can run cmake --build build --target xxx_lupdate
to update the ts
files. I also add an exception here, when you set the option CREATE_ONCE
, qm_add_translation
will generate the ts
files right away if the ts
files don't exist, provided all source files are available at configure phase, sometimes there are future source files generated at build phase.
cmake is not very proficient, thanks for the answer