Autogen contains code to forward dependencies from an origin target
to its associated <origin>_autogen target. This code also contains a
check to skip forwarding a dependency if it does not appear in the
dependency graph for all configured build types.
This is done by counting the number of times a dependency appears in
the graph for each configured build type.
Unfortunately the code did not account for the case when a dependency
appears more than once in the link graph for a single build type. This
means that for a single-config build, if the same dependency is linked
twice, the dependency will be skipped altogether.
This can lead to build errors in a project where a hypothetical App
target depends on a Lib target, and thus expects App_autogen to depend
on Lib_autogen and any of its dependencies, but the latter is skipped.
Fix this by incrementing the count of a target in the dependency graph
only once per build type.
Fixes: #26700
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Issue: #26123
When `ui_` include directives have different paths than `CMakeLists.txt`,
the dependency graph is not generated correctly. This is the root cause
of #16776. However, when #26135 was fixed by commit 5363bebc1e (Autogen:
Fix compilation of unchanged source files, 2024-07-16, v3.31.0-rc1~328^2),
it made #16776 worse: the build is always dirty. Revert the fix for now.
Fixes: #26485
Issue: #26135
Issue: #25436
In commit 5363bebc1e (Autogen: Fix compilation of unchanged source files,
2024-07-16, v3.31.0-rc1~328^2) we relied on Ninja Multi-Config dependency graph
optimizations from commit 7c39dabdbc (Autogen: AUTO*_EXECUTABLE: add support
for per-config values, 2023-10-18, v3.29.0-rc1~105^2~1). However, those graph
optimizations are conditional on versions of Qt that enable
[`AUTOGEN_BETTER_GRAPH_MULTI_CONFIG`](https://codereview.qt-project.org/c/qt/qtbase/+/513648).
`UseBetterGraph` should be checked to add ui files to `timestampByproducts`.
Fixes: #26475
Since commit 7c39dabdbc (Autogen: AUTO*_EXECUTABLE: add support for
per-config values, 2023-10-18, v3.29.0-rc1~105^2~1) we were accidentally
running cmake_autogen multiple times for each config.
Fixes: #26282
Since generated `ui` headers are added as byproducts of the autogen
target, it causes to compilation of unchanged files.
This commits adds generated `ui` headers to byproducts of the
timestamp target instead of the autogen target's.
Fixes: #25436Fixes: #26135
In the commit 8d99e71b, a new timestamp file was added to prevent
unneeded `AUTORCC` triggering after successful builds when
`CMAKE_GLOBAL_AUTORCC_TARGET` is ON. This caused a regression that
configuration fails when multiple `.qrc` files are added to a target.
This commits reverts 8d99e71b.
Issue: #26059Fixes: #26126
Since 2bfaaf6f6ed7481438bec08771992ea5152b5453 reorganized the dependency order for the `timestamp` target,
`<target_name>_autogen_timestamp_deps` is genetared as `phony edge with no inputs`. So this commit removes
`<target_name>_autogen_timestamp_deps`.
The dependency graph before
original dependencies of '_autogen' target <- _autogen_timestamp_deps <-'/timestamp' file <- '_autogen' target
The dependency graph after
original dependencies of '_autogen' target <-'/timestamp' file <- '_autogen' target
Fixes: #26080
When `CMAKE_GLOBAL_AUTORCC_TARGET` is ON and qrc files are not
generated, `<target_name>_arcc_data` is always dirty. So this commit
adds a timestamp file which depens on what `<target_name>_arcc_data`
depends before and ``<target_name>_arcc_data` depends the timestamp
file.
The dependency graph before
(qrcFile, InfoFile) -> _arcc_target
The dependency graph after
(qrcFile, InfoFile) -> global_rcc_timestamp ->_arcc_target
Fixes: #26059
Since commit 1e49880472 (cmGeneratorTarget: Avoid boolean trap in usage
requirement lookup, 2021-12-08, v3.23.0-rc1~245^2) we have clarified
the distinction between compile-only and link-only usage requirements.
Rename the `LinkInterfaceFor` enum to `UseTo` to clarify that its role
is to specify the purpose of usage requirements.
We place the same target ordering dependencies on either the
`_autogen_timestamp_deps` target or the `_autogen` target.
Refactor the logic to avoid duplicating that code.
In commit aebfbcaa46 (AutoGen: Use depfiles for the XXX_autogen ninja
targets, 2020-01-14, v3.17.0-rc1~58^2) the `_autogen_timestamp_deps`
target was given target ordering dependencies through its custom command
rather than direct target dependencies as on the `_autogen` target.
Then commit 895fa3433f (cmQtAutoGenInitializer: support IMPLIB-only
imported targets, 2021-09-23, v3.22.0-rc1~80^2) converted some
target-level dependencies into file-level dependencies on the custom
command. This only works with a monolithic build graph like Ninja.
Since commit ebc9e448b3 (Autogen: Add depfile support for Makefiles,
2023-09-07, v3.28.0-rc1~101^2~1) we use the `_autogen_timestamp_deps`
target in Makefile generators too. This exposed the missing target
ordering dependency.
Fixes: #25766
Add the `--no-zstd` argument for `RCC` when `QT_FEATURE_zstd` is `OFF`.
This causes user project builds to fail. That bug is fixed in Qt
by https://codereview.qt-project.org/c/qt/qtbase/+/537546 but for
the older versions, fix it here too.
Fixes: #25664
d0bedb2170 Autogen: Forward dependencies when both Makefile and DEPFILE are used
4deb9c41b8 cmQtAutoGenInitializer: Improve Const-correctness
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9190
Since commit ebc9e448b3 (Autogen: Add depfile support for Makefiles,
2023-09-07, v3.28.0-rc1~101^2~1) CMake does not generate the correct
dependency graph when both `Makefile` and `DEPFILE` are used.
The build of `<target_name>_autogen_timestamp_deps` fails due to
missing dependencies. To tackle that problem, forward target
dependencies to both `<target_name>_autogen_timestamp_deps` and
`<target_name>_autogen` instead of just `<target_name>_autogen`.
Fixes: #25600
* Per-config values were added to `AUTO*_EXECUTABLE`.
* Dependency order was refactored for `cmake_autogen` and `cmake_autorcc` to avoid unnecessary rebuilds.
* A new parameter was added for `cmake_autogen` and `cmake_autorcc` to specify the config name of the `auto*_executable` to be used.
* Add `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` target property to change the behavior of the dependency graph.
* The timestamp target is split into three targets for per-config to avoid redundant `mocs_compilation` builds when `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` is ON
* Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `Multi-Config` usage.
* Some functions were refactored to avoid code duplication.
This commit reimplements fddd0f0443b4ce81d61f15ee1b2f13105967b25a
Fixes: #20074
Changing the `timestamp` file to `timestamp_$<CONFIG>` causes some user
projects to break when using Qt versions older than 6.6.
Revert commit fddd0f0443 (Autogen: AUTO*_EXECUTABLE: add support for
per-config values, 2023-06-14, v3.28.0-rc1~96^2~1) pending further
investigation.
Issue: #20074
Since commit fddd0f0443 (Autogen: AUTO*_EXECUTABLE: add support for
per-config values, 2023-06-14) we do not correctly generate outputs
for one configuration after another configuration has been built.
Fix this:
- Revert some config based stuff for `Xcode` due to the `$<CONFIG>`
genex usage limitation in source files with `Xcode`.
- For multi-config generators use a per-config `timestamp_$<CONFIG>`
file instead of one `timestamp` file.
Fixes: #25261
* Per-config values were added to `AUTO*_EXECUTABLE`.
* Dependency order was refactored for `cmake_autogen` and `cmake_autorcc` to
avoid unnecessary rebuilds.
* A new parameter was added for `cmake_autogen` and `cmake_autorcc` to specify the config name of the `auto*_executable` to be used.
* The timestamp target was split into three targets for per-config to avoid redundant `mocs_compilation` builds.
* Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `CMAKE_CROSS_CONFIG` usage.
* Some functions were refactored to avoid code duplication.
Fixes: #20074
The default config was an empty string when a `multi-config`
generator is used. An if check was added for those situations.
If a source file has a specific config configuration,
it is used with `$<CONFIG>` in the `multi-config` generator usage.
Fixes: #24848
The redundant `cmake_autogen` process execution was optimized for
non-`CROSS_CONFIGS` usage. It was executed three times for each
config although only one of them is needed.