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

qtquick_compiler_add_resources do not handle adding new qml files gracefully

    XMLWordPrintable

Details

    • All
    • dd9e41d1a5138fd58759c847525de7453efd2f00 (qt/qtdeclarative/5.15) 749ca5d0272eec49c2986eecebe897d311cbf372 (qt/qtdeclarative/5.15)

    Description

      For such simplified cmake file (created by qt creator and stripped from android support):

      cmake_minimum_required(VERSION 3.5)
      
      project(cmake_compile_qml LANGUAGES CXX)
      
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      find_package(Qt5 COMPONENTS Core Quick QuickCompiler REQUIRED)
      
      qtquick_compiler_add_resources(gui_RCC_SRCS qml.qrc)
      #qt_add_resources(gui_RCC_SRCS qml.qrc)
      
      add_executable(cmake_compile_qml
        main.cpp
        ${gui_RCC_SRCS}
        )
      target_compile_definitions(cmake_compile_qml
        PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
      target_link_libraries(cmake_compile_qml
        PRIVATE Qt5::Core Qt5::Quick)
      

      and qml.qrc:

      <RCC>
          <qresource prefix="/">
              <file>main.qml</file>
              </qresource>
      </RCC>
      

      all works fine at least for Linux/ninja/make and macOS/iOS/xcode.

      But if add new qml file (Hello.qml):

      <RCC>
          <qresource prefix="/">
              <file>main.qml</file>
              <file>Hello.qml</file> 
          </qresource>
      </RCC>
      

      build failed with such error:

      /usr/bin/ld: CMakeFiles/cmake_compile_qml.dir/qmlcache_loader.cpp.o:(.data.rel.ro+0x20): undefined reference to `QmlCacheGeneratedCode::_0x5f__Hello_qml::qmlData'
      collect2: error: ld returned 1 exit status
      make[2]: *** [CMakeFiles/cmake_compile_qml.dir/build.make:169: cmake_compile_qml] Error 1
      make[1]: *** [CMakeFiles/Makefile2:96: CMakeFiles/cmake_compile_qml.dir/all] Error 2
      make: *** [Makefile:104: all] Error 2
      

      I have to rerun cmake and only then I can compile project successfully.
      By the way the same problem if I build cmake project in Qt Creator.

      All works fine if I comment qtquick_compiler_add_resources and uncomment qt_add_resources, I can add new files without problem.

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            evgeniy_dushistov evgeniy_dushistov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes