Skip to content

CMake: Fix qt5_create_translation for same-named .ts files

Downstream report: https://bugs.gentoo.org/905698 Draft until finally integrated upstream.

Fixes regression in Qt's CMake translation API.

Bug reported here: qt5_create_translation breaks projects with multiple same-named ts files https://bugreports.qt.io/browse/QTBUG-113152

Backport of upstream patch: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270868#c4 https://people.freebsd.org/~tcberner/patches/0001-Qt-Update-Qt5-to-5.15.9.patch.v2

Consider a project where .ts files are structured by directory instead
of by file name:

translations/chinese/myapp.ts
translations/czech/myapp.ts
translations/french/myapp.ts
translations/german/myapp.ts
translations/italian/myapp.ts

In that case, qt5_create_translations failed at configure time with the
following error:

  Attempt to add a custom rule to output

    /build/myapp/.lupdate/myapp.ts.stamp.rule

  which already has a custom rule.

Fix that by constructing a .ts.stamp file path that takes the relative
path from CMAKE_CURRENT_SOURCE_DIR to the .ts file into account.

Additionally, pass the paths of the timestamp files to
qt5_add_translation with the __QT_INTERNAL_TIMESTAMP_FILES multi-value
argument to avoid having to recalculate the paths of the timestamp
files.

Pick-to: 6.5 5.15
Fixes: QTBUG-113152
Change-Id: Ifa08741cd621f2215eaf2f8fb848ecf6d5b9cf13

Signed-off-by: Andreas Sturmlechner asturm@gentoo.org

Merge request reports

Loading