Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86192

QT5_CREATE_TRANSLATION doesn't set directory dependencies correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.1.0 RC
    • 5.14.2
    • None
    • CMake 3.18.1
      Visual Studio 2019
    • All
    • 2834bebc9e6ba9bf0577db1d7da42a52e622adc6 (qt/qttools/dev) c7d34b9090d5b08310e27be17f46b23a24d9d7cb (qt/qttools/5.15)

    Description

      When using the QT5_CREATE_TRANSLATION function provided by Qt5LinguistToolsMacros.cmake, it's possible to specify a directory as one of the sources. This is passed to lupdate which handles it just fine, and as one of the values for the DEPENDS argument of the add_custom_command call, which isn't handled well.

      CMake (at least with some generators, including Visual Studio solutions) doesn't permit directories to be listed as dependencies for commands. In particular, MSBuild re-runs lupdate regardless of whether any of its inputs have been changed, and emits a warning of the form warning MSB8064: Custom build for item "<cmake binary dir>\CMakeFiles\<some hex>\<ts file name>.rule" succeeded, but specified dependency "<the directory specified as a source>" does not exist. This may cause incremental builds to work incorrectly.

      Obviously, the dependency actually does exist, but is a directory rather than a file, and while the build does succeed, time is wasted running lupdate and lrelease unnecessarily, and warnings are undesirable.

      I've altered the file locally to:

      • Check if a custom list of extensions has been passed with -extensions, and build a list based on that, or use the default.
      • Check if each specified source is a directory, and if so:
        • Generate globbing expressions for the list of extensions to be used.
        • Search the specified directory for matching files.
        • Add those files to the list of dependencies to give to CMake instead of the directory itself.

      As intended, this removes the warning, prevents lupdate from being run when there are no changes, and makes a rebuild with no changes finish faster. A patch is attached.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kkohne Kai Köhne
            anyoldname3 Chris Djali
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes