Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.2.0
-
None
-
Ubuntu Linux 20.04 (x86_64)
Qt Creator 5.0.2
Qt 6.2.0
-
-
23b348e9e9583c8face308e58fcd2ac14f905b4d (qt/qttools/dev) 5af54b2040a04015627d65e96b77f7d8df4b010e (qt/qttools/6.2) c2b42232ae9723a2811bb601cab53043e0e6efa4 (qt/qttools/6.2.1)
Description
The issue can be reproduced with Qt Creator and a CMake project.
- Use:
set(TS_FILES bug_test_en.ts bug_test_de.ts bug_test_it.ts) qt_add_lupdate(bug_test TS_FILES ${TS_FILES})
run CMake, go into the build directory and look into the .lupdate/bug_test_project.cmake file.
You will find a row starting withset(lupdate_sources "...
followed by all the sources associated to the executable by the qt_add_executable() call.
- Now suppose you want to limit the translation process to a subset of the sources; for example:
set(SOURCES_A src_a_1.cpp src_a_1.h src_a_2.cpp src_a_2.h) set(SOURCES_B src_b_1.cpp src_b_1.h src_b_2.cpp src_b_2.h) qt_add_executable(bug_test ${SOURCES_A} ${SOURCES_B}) qt_add_lupdate(${CMAKE_PROJECT_NAME} TS_FILES ${TS_FILES} SOURCES ${SOURCES_A})
run CMake, go into the build directory and look into the .lupdate/bug_test_project.cmake file.
You will find that the lupdate_sources variable is set to an empty string, like thisset(lupdate_sources "")
This makes the call to the update_translations target not working (all the existing translations turn to vanished).
NB: the INCLUDE_DIRECTORIES argument should suffer from the same issue.
A workaround (and suggested fixup) is:
- locate the Qt6LinguistToolsMacros.cmake file in the Qt installation path
- locate the function(qt6_add_lupdate target) definition (it should be at about line 148)
- locate the block
if(NOT arg_INCLUDE_DIRECTORIES) set(includePaths "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>") endif() if(NOT arg_SOURCES) set(sources "$<TARGET_PROPERTY:${target},SOURCES>") endif()
(it should be at about line 161) and turn it into
if(NOT arg_INCLUDE_DIRECTORIES) set(includePaths "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>") else() qt_internal_make_paths_absolute(includePaths "${arg_INCLUDE_DIRECTORIES}") endif() if(NOT arg_SOURCES) set(sources "$<TARGET_PROPERTY:${target},SOURCES>") else() qt_internal_make_paths_absolute(sources "${arg_SOURCES}") endif()