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

qt_add_qml_module: _automoc_json_extraction target and resources are rebuilding every time with Visual Studio Generator

    XMLWordPrintable

Details

    • Windows
    • e0ec19de4 (dev), 99aeb7594 (6.5), 470fee321 (dev), 1e303cdbd (6.6), a945c542d (6.5), b6f777824 (tqtc/lts-6.2), ec5fee55e (6.5.2)

    Description

      Hi,

      I was trying out the new qt_add_qml_module CMake-macro that came with Qt 6.2 to create reusable QML modules.

      In Visual Studio I noticed that it will always re-build rcc files even when nothing has changed.

      I used the following example project https://gitlab.com/kelteseth/qt6-cmake-qml-plugin-example-project and QT 6.3.2 via vcpkg.

      After a full project build and without changing any source files, the rcc-generated files still always get recompiled when MSBuild gets invoked:

      1>------ Build started: Project: DownloadManager_qmlcache_autogen, Configuration: Debug x64 ------
      2>------ Build started: Project: DownloadManagerplugin_init_autogen, Configuration: Debug x64 ------
      3>------ Build started: Project: TestProject_qmlimportscan, Configuration: Debug x64 ------
      4>------ Build started: Project: DownloadManager_autogen, Configuration: Debug x64 ------
      1>Automatic MOC for target DownloadManager_qmlcache
      2>Automatic MOC for target DownloadManagerplugin_init
      4>Automatic MOC for target DownloadManager
      5>------ Build started: Project: DownloadManager_automoc_json_extraction, Configuration: Debug x64 ------
      5>Running AUTOMOC file extraction for target DownloadManager
      6>------ Build started: Project: DownloadManager, Configuration: Debug x64 ------
      6>Running moc --collect-json for target DownloadManager
      6>Automatic QML type registration for target DownloadManager
      6>Generating .rcc/qmlcache/DownloadManager_DownloadManager/TestMain_qml.cpp
      6>Generating .rcc/qmlcache/DownloadManager_DownloadManager/DownloadManagerControls_qml.cpp
      6>DownloadManagerControls_qml.cpp
      6>TestMain_qml.cpp
      6>downloadmanager_qmltyperegistrations.cpp
      6>DownloadManager.vcxproj -> F:\Temp\testbuild\Debug\DownloadManager.lib
      7>------ Build started: Project: TestProject, Configuration: Debug x64 ------
      7>Automatic MOC for target TestProject
      7>TestProject.vcxproj -> F:\Temp\testbuild\Debug\TestProject.exe
      ========== Build: 7 succeeded, 0 failed, 7 up-to-date, 0 skipped ==========
      

      Even with only two QML-resources, the build already takes more than 4 seconds every time. The Visual Studio re-build times on larger projects with more resources would be horribly slow.

      Through the verbose MSBuild output I figured out that the source of the resource-build being triggered lies in the _automoc_json_extraction Utility-target. It gets re-generated every time because the output file mentioned in the custom build step is never created:

      <ItemGroup>
          <CustomBuild Include="F:\Temp\testbuild\CMakeFiles\da9815ec55e86dcf9777446cf05e6423\DownloadManager_automoc_json_extraction.rule">
            <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Running AUTOMOC file extraction for target DownloadManager</Message>
            <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">setlocal
      G:\vcpkg\installed\x64-windows\tools\Qt6\bin\cmake_automoc_parser.exe --cmake-autogen-cache-file F:/Temp/testbuild/CMakeFiles/DownloadManager_autogen.dir/ParseCache_Debug.txt --cmake-autogen-info-file F:/Temp/testbuild/CMakeFiles/DownloadManager_autogen.dir/AutogenInfo.json --output-file-path F:/Temp/testbuild/meta_types/DownloadManager_json_file_list.txt --timestamp-file-path F:/Temp/testbuild/meta_types/DownloadManager_json_file_list.txt.timestamp --cmake-autogen-include-dir-path F:/Temp/testbuild/DownloadManager_autogen/include_Debug --cmake-multi-config
      if %errorlevel% neq 0 goto :cmEnd
      :cmEnd
      endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
      :cmErrorLevel
      exit /b %1
      :cmDone
      if %errorlevel% neq 0 goto :VCEnd</Command>
            <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">G:\vcpkg\installed\x64-windows\tools\Qt6\bin\cmake_automoc_parser.exe;%(AdditionalInputs)</AdditionalInputs>
            <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">F:\Temp\testbuild\CMakeFiles\DownloadManager_automoc_json_extraction</Outputs>
            <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkObjects>
            <VerifyInputsAndOutputsExist Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</VerifyInputsAndOutputsExist>
      

      If i manually create the file "F:\Temp\testbuild\CMakeFiles\DownloadManager_automoc_json_extraction" the target is not re-built, but consequentially actual re-builds may not get triggered when necessary.

      When using Ninja as the CMake generator, everything behaves as expected and no files are re-built without changes. Thus, this seems to be an issue that specifically affects only the Visual Studio CMake generators.
       

      Attachments

        Issue Links

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

          Activity

            People

              jbornema Joerg Bornemann
              mwechner Michael Wechner
              Votes:
              6 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: