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

Cannot generate qmldir on same URI in qt_add_qml_module

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.6.2, 6.7.0 Beta3
    • None

    Description

      We use qt_add_qml_module to generate our productive and development module. We use the same URI "Company.modulename" for the modules but with different RESOURCE_PREFIX as we switch the qml import path at runtime to switch between productive and development UI.

      This works really nice. Since we have manually created qmldirs we wanted to switch to automatically generated qmldirs. But it won't link anymore because generated qrc file for the qmldir is not unique.

      ld.lld: error: duplicate symbol: qInitResources_qmake_Company_MoreView()
      >>> defined at qrc_qmake_Company_MoreView.cpp:102 (src/ui/qml/modules/.rcc/qrc_qmake_Company_MoreView.cpp:102)
      >>>            src/ui/qml/modules/CMakeFiles/QmlModuleProductiveMoreView_resources_1.dir/./.rcc/qrc_qmake_Company_MoreView.cpp.o:(qInitResources_qmake_Company_MoreView())
      >>> defined at qrc_qmake_Company_MoreView.cpp:102 (src/ui/qml/modules/.rcc/qrc_qmake_Company_MoreView.cpp:102)
      >>>            src/ui/qml/modules/CMakeFiles/QmlModuleDevelopmentMoreView_resources_1.dir/./.rcc/qrc_qmake_Company_MoreView.cpp.o:(.text+0x0)
      
      ld.lld: error: duplicate symbol: qCleanupResources_qmake_Company_MoreView()
      >>> defined at qrc_qmake_Company_MoreView.cpp:111 (src/ui/qml/modules/.rcc/qrc_qmake_Company_MoreView.cpp:111)
      >>>            src/ui/qml/modules/CMakeFiles/QmlModuleProductiveMoreView_resources_1.dir/./.rcc/qrc_qmake_Company_MoreView.cpp.o:(qCleanupResources_qmake_Company_MoreView())
      >>> defined at qrc_qmake_Company_MoreView.cpp:111 (src/ui/qml/modules/.rcc/qrc_qmake_Company_MoreView.cpp:111)
      >>>            src/ui/qml/modules/CMakeFiles/QmlModuleDevelopmentMoreView_resources_1.dir/./.rcc/qrc_qmake_Company_MoreView.cpp.o:(.text+0x40)
      

      Seems "qmake_Company_Animations.qrc" will be overwritten with any new qt_add_qml_module.

      $ ll .rcc/
      1,9K 11. Mär 14:47 QmlModuleProductiveAnimations_raw_qml_0.qrc
      1,9K 11. Mär 14:47 QmlModuleDevelopmentAnimations_raw_qml_0.qrc
       220 11. Mär 14:46 qmake_Company_Animations.qrc
      

      It would be better if the generated qrc file "qmake_Company_Animations.qrc" had a unique file name of the backing target.
      Is the comment in Qt6QmlMacros.cmake:527 still up-to-date?

              # Embed qmldir in qrc. The following comments relate mostly to Qt5->6 transition.
              # The requirement to keep the same resource name might no longer apply, but it doesn't
              # currently appear to cause any hinderance to keep it.
              # The qmldir resource name needs to match the one generated by qmake's qml_module.prf, to
              # ensure that all Q_INIT_RESOURCE(resource_name) calls in Qt code don't lead to undefined
              # symbol errors when linking an application project.
              # The Q_INIT_RESOURCE() calls are not strictly necessary anymore because the CMake Qt
              # build passes around the compiled resources as object files.
              # These object files have global initiliazers that don't get discared when linked into
              # an application (as opposed to when the resource libraries were embedded into the static
              # libraries when Qt was built with qmake).
              # The reason to match the naming is to ensure that applications link successfully regardless
              # if Qt was built with CMake or qmake, while the build system transition phase is still
              # happening.
              string(REPLACE "/" "_" qmldir_resource_name "qmake_${arg_TARGET_PATH}")
      

      Used

      		qt_add_qml_module(${ModuleLibrary}
      			URI "Company.${name}"
      			VERSION "${PROJECT_VERSION}"
      			QML_FILES ${files}
      			OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_system}/Company/${name}
      			NO_CACHEGEN
      			${RESOURCE_PREFIX}
      		)
      

      Attachments

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

        Activity

          People

            qtbuildsystem Qt Build System Team
            misery André Klitzing
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes