Commit c17fc36d authored by Joerg Bornemann's avatar Joerg Bornemann
Browse files

Fix permanently out-of-date .qm files


An incremental build without changed .ts files must be a null build.
However, the .qm files were always re-generated.  That was, because
add_custom_target was used to run lrelease, and such targets are always
out of date.

Use the new target-based translation API that uses add_custom_command
under the hood.  This fixes the described issue and simplifies the
project file a lot.

For the target that runs lupdate: the .ts file must not be a by-product
of the custom target.  Otherwise, the updateqm target would trigger the
ts-${catalog}-${lang} targets.  There should be no connection between
the lrelease and lupdate targets.

Pick-to: 6.2
Fixes: QTBUG-96038
Change-Id: I1faf35f1eab154be3a12dfaed93d64799dbb6ff1
Reviewed-by: default avatarAlexey Edelev <alexey.edelev@qt.io>
Reviewed-by: default avatarAlexandru Croitor <alexandru.croitor@qt.io>
parent dbcf76dc
No related merge requests found
Showing with 8 additions and 25 deletions
...@@ -14,7 +14,6 @@ endfunction() ...@@ -14,7 +14,6 @@ endfunction()
function(add_ts_target target input_file output_file) function(add_ts_target target input_file output_file)
add_custom_target(${target} add_custom_target(${target}
BYPRODUCTS ${output_file}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::lupdate -locations relative -no-ui-lines -no-sort "@${input_file}" -ts ${output_file} COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::lupdate -locations relative -no-ui-lines -no-sort "@${input_file}" -ts ${output_file}
) )
endfunction() endfunction()
...@@ -131,6 +130,8 @@ add_dependencies(check-ts ts-all) ...@@ -131,6 +130,8 @@ add_dependencies(check-ts ts-all)
add_custom_target(updateqm ALL) add_custom_target(updateqm ALL)
file(GLOB ts_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.ts") file(GLOB ts_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.ts")
file(GLOB en_ts_files "${en_ts_file_dir}/*.ts")
list(APPEND ts_files ${en_ts_files})
if(QT_WILL_INSTALL) if(QT_WILL_INSTALL)
set(qm_output_dir "${QT_BUILD_DIR}/${INSTALL_TRANSLATIONSDIR}") set(qm_output_dir "${QT_BUILD_DIR}/${INSTALL_TRANSLATIONSDIR}")
...@@ -138,30 +139,12 @@ else() ...@@ -138,30 +139,12 @@ else()
set(qm_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_TRANSLATIONSDIR}") set(qm_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_TRANSLATIONSDIR}")
endif() endif()
foreach(file IN LISTS ts_files) set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION "${qm_output_dir}")
string(REGEX REPLACE "\\.ts$" ".qm" qm_file ${file}) qt_add_lrelease(updateqm
set(output_file "${qm_output_dir}/${qm_file}") TS_FILES ${ts_files}
add_custom_target(updateqm-${file} NO_GLOBAL_TARGET
BYPRODUCTS ${output_file} QM_FILES_OUTPUT_VARIABLE qm_files)
COMMAND "${CMAKE_COMMAND}" -E make_directory "${qm_output_dir}" qt_install(FILES ${qm_files} DESTINATION "${INSTALL_TRANSLATIONSDIR}")
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::lrelease "${CMAKE_CURRENT_SOURCE_DIR}/${file}" -qm "${output_file}"
)
qt_install(FILES ${output_file} DESTINATION "${INSTALL_TRANSLATIONSDIR}")
add_dependencies(updateqm updateqm-${file})
endforeach()
file(GLOB ts_files RELATIVE ${en_ts_file_dir} "${en_ts_file_dir}/*.ts")
foreach(file IN LISTS ts_files)
string(REGEX REPLACE "\\.ts$" ".qm" qm_file ${file})
set(output_file "${qm_output_dir}/${qm_file}")
add_custom_target(updateqm-${file}
BYPRODUCTS ${output_file}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::lrelease "${en_ts_file_dir}/${file}" -qm "${output_file}"
)
qt_install(FILES ${output_file} DESTINATION "${INSTALL_TRANSLATIONSDIR}")
add_dependencies(updateqm updateqm-${file})
endforeach()
# Custom target to add modified ts files to git # Custom target to add modified ts files to git
add_custom_target(stage-ts add_custom_target(stage-ts
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment