Go to file
Joerg Bornemann e0ec19de41 CMake: Fix unnecessary rebuilds in Visual Studio projects
User projects that use qt_add_qml_module faced unnecessary rebuilds when
using the Unix Makefiles or Visual Studio project generators.

The bug was in qt6_extract_metatypes. For the mentioned generators (and
CMake 3.16 in general), we detect that CMake's AUTOMOC does not generate
a dep file, and we use a custom target to trigger cmake_automoc_parser.
That custom target runs always.

Later, we call moc to generate meta_types/foo_metatypes.json.gen. To not
trigger a rebuild of its dependents on every build, we use
copy_if_different to generate meta_types/foo_metatypes.json only if the
content changed.

The custom command for that had two outputs:
     add_custom_command(
         OUTPUT
             ${metatypes_file_gen}
             ${metatypes_file}
         ...
     )

The Unix Makefile generator and the Visual Studio generator (and
potentiall others) interpret this as "all outputs are always changed by
this command". The Unix Makefile generator even ensures that by creating
an additional foo_metatypes.json target that touches the file. In the
generated Visual Studio project, the dependents of foo_metatypes.json
are out of date even if the actual file has an old timestamp.

In projects with QML modules, the QML type registration depends on this
file. This caused a near full rebuild of the affected QML modules.

We must mark foo_metatypes.json as byproduct of the command to specify
that it is a file "whose modification time may or may not be newer than
the dependencies".

Unfortunately, there's CMake upstream issue #19005. There's a dependency
missing between the consuming target and the byproduct. We must work
around this issue with an additional custom command with OUTPUT
${metatypes_file}.

Pick-to: 6.5
Fixes: QTBUG-106683
Change-Id: Icc2f7227c3e7b523631c1f361e29e26ae4efc46c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-04 20:44:39 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Add simple project generation based on existing source files 2023-02-08 12:59:19 +01:00
cmake Generate and set a CFBundleIdentifier when none were provided on macOS 2023-06-02 19:28:04 +02:00
coin Add Axivion analysis commands 2023-05-17 14:04:48 +03:00
config.tests Remove the mandatory x86-64 features from its feature list 2023-05-31 14:55:37 -07:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Move widgets Application example to manual tests 2023-06-04 01:18:19 +02:00
examples Move widgets Application example to manual tests 2023-06-04 01:18:19 +02:00
lib
libexec Pass native path in qt-internal-configure-tests 2023-04-17 23:32:34 +02:00
LICENSES Clarify license of SHA-1 algorithm 2023-04-26 16:36:18 +02:00
mkspecs iOS: Don't add Qt libraries to PRE_TARGETDEPS of xcodebuild Makefile 2023-05-10 16:37:47 +02:00
qmake CMake: make compile options consistent for Qt created libraries 2023-05-31 01:08:45 +00:00
src CMake: Fix unnecessary rebuilds in Visual Studio projects 2023-06-04 20:44:39 +02:00
tests QString: add STL-style assign() [1/4]: non-(it,it) overloads 2023-06-04 06:33:12 +00:00
util qsimd_x86: update from upstream and enable a few more features 2023-05-26 16:22:22 -07:00
.cmake.conf Centralize copyright information for Qt 2023-03-20 13:03:44 +01:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore git: ignore ._* files 2023-03-28 10:44:57 +02:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag
CMakeLists.txt Introduce QT_ALLOW_SYMLINK_IN_PATHS flag 2023-05-03 19:44:45 +02:00
conanfile.py Conan: Do not force 'qt_host_path' usage in cross-build context 2022-06-22 18:18:42 +03:00
config_help.txt Remove the -sysroot option from configure 2023-05-12 09:46:24 +02:00
configure Retrieve an old -redo behavior 2023-02-07 18:51:58 +00:00
configure.bat Retrieve an old -redo behavior 2023-02-07 18:51:58 +00:00
configure.cmake configure: Make -ccache work for msvc 2023-05-09 23:21:13 +02:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
qt_cmdline.cmake Remove the -no-gcc-sysroot configure option 2023-05-26 17:44:53 +02:00
sync.profile rhi: Make it a QPA-style private but semi-public API 2023-05-21 15:42:58 +02:00