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

'lupdate_sources' variable empty in cmake file generated by qt_add_lupdate

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.1, 6.3.0 Alpha
    • 6.2.0
    • Build System: CMake
    • None
    • Ubuntu Linux 20.04 (x86_64)
      Qt Creator 5.0.2
      Qt 6.2.0
    • All
    • 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 with

         set(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 this

        set(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:

      1. locate the Qt6LinguistToolsMacros.cmake file in the Qt installation path
      2. locate the function(qt6_add_lupdate target) definition (it should be at about line 148)
      3. 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()
        

      Attachments

        For Gerrit Dashboard: QTBUG-97389
        # Subject Branch Project Status CR V

        Activity

          People

            jbornema Joerg Bornemann
            flinco Lorenzo Buzzi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes