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

Avoid rebuilding all mocs dependencies after running CMake on MSVC

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.4.2, 6.5.3
    • None
      • Windows 11 64-bits 22H2
      • QtCreator 11.0.3
      • CMake 3.24.2, generator: Ninja 1.10.2
      • MSVC2019 17.0.31919.166
    • Windows

    Description

      We have a project with ~5000 files, with ~half of them being QObject sub-classes.

      Using this project with QtCreator, CMake and the MSVC2019 compiler, each time a file is added to the project and CMake is re-run, MOC seem to be reexecuted and it causes the recompilation of ~2500 files that haven't changed, wasting a lot of time (~10 min) each time.

      This seems to be due to the MOC compiler overwritting all mocs during CMake and causing the compiler to recompile a lot of stuff for nothing, just because the file timestamp has changed.

      If this is confirmed, maybe an option to avoid this could be in the MOC compiler to not simply overwrite a file on disk if there is already a file with an identical content at the same path, thus not changing the timestamp of the file if its content does not change. This means to read the file on disk (if it exists), compare its content with what is about to be written, and only write it if different.

      We have applied this pattern to a code generator that generates C++ message classes for communication during the CMake step and it works well, saving precious time daily.

      NOTE: This issue does not appear on Linux with ccache enabled.

      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
            a.habersaat Alexandre Habersaat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes