1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-11 23:57:42 +08:00

257 Commits

Author SHA1 Message Date
Brad King
5ac3cca63d Merge branch 'backport-3.31-custom-transitive-properties' (early part) 2025-02-22 09:41:13 -05:00
Brad King
2ccbad90e6 cmGeneratorExpressionDAGChecker: Construct with initializer list syntax 2025-02-22 09:11:20 -05:00
Alexandru Croitor
2b314e9009 Autogen: Fix missing autogen dependencies if a target is linked twice
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
2025-02-13 14:33:41 -05:00
Alex Turbov
d34971f455 Refactor: Eliminate redundant std::to_string as arg of cmStrCat
Plus optimize some other string operations in the modified files.
2025-01-26 04:03:38 +04:00
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
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
2025-01-23 13:09:50 -05:00
Brad King
ef26f74442 Merge topic 'autogen-revert-ui-rebuild'
debc4d3906 Autogen: Revert adding ui files to byproducts of the timestamp target

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10056
2024-12-05 08:10:36 -05:00
Orkun Tokdemir
debc4d3906 Autogen: Revert adding ui files to byproducts of the timestamp target
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
2024-12-04 12:37:13 +01:00
Brad King
5aebb62d0c Merge topic 'autogen-ninja-multi-config'
8a526f6a44 Autogen: Fix Ninja Multi-Config dependency graph regression
3cac48e8cd Autogen: Restore <target_name>_autogen_timestamp_deps target

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10039
2024-11-29 09:57:21 -05:00
Orkun Tokdemir
8a526f6a44 Autogen: Fix Ninja Multi-Config dependency graph regression
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
2024-11-28 09:13:56 -05:00
Orkun Tokdemir
3cac48e8cd Autogen: Restore <target_name>_autogen_timestamp_deps target
Revert commit 91b2ce4a69 (Autogen: Remove ..._autogen_timestamp_deps
target, 2024-06-27, v3.31.0-rc1~391^2).  The `_autogen_timestamp_deps`
target is needed for pre-`AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` behavior.

Issue: #26080
Issue: #26475
2024-11-28 09:13:46 -05:00
Brad King
659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Daniel Pfeifer
58c5f77837 clang-tidy: fix readability-redundant-* warnings 2024-10-11 15:37:21 +02:00
Orkun Tokdemir
32c8cb2960 Autogen: Avoid running multiple cmake_autogen command in Xcode
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
2024-09-15 15:49:02 +02:00
Vitaly Stakhovsky
58da4aa47d Source: Avoid comparing pointers to nullptr 2024-08-27 10:56:38 -04:00
Orkun Tokdemir
5363bebc1e Autogen: Fix compilation of unchanged source files
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: #25436
Fixes: #26135
2024-07-17 18:12:04 +02:00
Orkun Tokdemir
9ffac91e37 Autogen: Revert "Add timestamp file for CMAKE_GLOBAL_AUTORCC_TARGET"
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: #26059
Fixes: #26126
2024-07-10 15:22:02 +02:00
Brad King
db7d89369a Merge topic 'orkun_26080_27_06_2024'
91b2ce4a69 Autogen: Remove <target_name>_autogen_timestamp_deps target

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9631
2024-07-02 08:33:48 -04:00
Orkun Tokdemir
91b2ce4a69 Autogen: Remove <target_name>_autogen_timestamp_deps target
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
2024-06-27 15:43:05 +02:00
Orkun Tokdemir
8d99e71b7e Autogen: Add timestamp file for CMAKE_GLOBAL_AUTORCC_TARGET
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
2024-06-26 15:37:41 +02:00
Orkun Tokdemir
003830f14f Autogen: Remove redundant push_back 2024-06-26 15:33:19 +02:00
Brad King
633afa0b2e cmGeneratorExpressionDAGChecker: Make config name available in constructor 2024-05-21 09:22:51 -04:00
Brad King
ff1693cb3c cmGeneratorTarget: Clarify enum for specifying purpose of usage requirements
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.
2024-05-03 13:04:10 -04:00
Brad King
e8010b67c7 cmGeneratorExpressionDAGChecker: Make local generator available in constructor
This is the local generator in the evaluation context, not that of
the current target/property pair.
2024-04-29 17:27:35 -04:00
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Brad King
2bfaaf6f6e Merge topic 'autogen-makefile-depfile'
d2d1763f88 cmQtAutoGenInitializer: De-duplicate autogen/timestamp target depend logic
6193d15556 Autogen: Restore target-ordering dependencies in Makefiles with DEPFILE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9340
2024-03-14 11:46:54 -04:00
Brad King
d2d1763f88 cmQtAutoGenInitializer: De-duplicate autogen/timestamp target depend logic
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.
2024-03-14 09:18:56 -04:00
Brad King
6193d15556 Autogen: Restore target-ordering dependencies in Makefiles with DEPFILE
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
2024-03-14 09:05:06 -04:00
Orkun Tokdemir
9e87df4d46 Autogen/RCC: Disable zstd if it is not supported
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
2024-02-09 09:10:41 -05:00
Brad King
28e89baa22 Merge topic 'autogen-makefile-depfile'
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
2024-01-29 10:43:45 -05:00
Orkun Tokdemir
d0bedb2170 Autogen: Forward dependencies when both Makefile and DEPFILE are used
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
2024-01-28 09:40:47 -05:00
Orkun Tokdemir
4deb9c41b8 cmQtAutoGenInitializer: Improve Const-correctness 2024-01-26 09:50:35 -05:00
Orkun Tokdemir
7c39dabdbc Autogen: AUTO*_EXECUTABLE: add support for per-config values
* 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
2024-01-17 16:02:58 +01:00
Brad King
dbede7be7e Merge topic 'cmake-sources-no-scan'
91b7bf59a7 cmGlobalXCodeGenerator: disable C++ module scanning for force-lang files
9e19a61ddb cmLocalGenerator: disable C++ module scanning for unity sources
fa9a72a788 cmLocalGenerator: disable C++ module scanning for copied PCH sources
e5dce1a37e cmQtAutoGenInitializer: disable C++ module scanning for autogen sources
4fd596c34c cmGeneratorTarget: disable C++ module scanning for verify targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9064
2023-12-12 08:33:38 -05:00
Ben Boeckel
e5dce1a37e cmQtAutoGenInitializer: disable C++ module scanning for autogen sources 2023-12-11 07:52:50 -05:00
tophoo
7a07887055 Autogen: Add support for response files for moc predef targets
Add support for response files for moc predef targets and make the limit when
to use response files for autogen targets configurable.
2023-11-16 16:29:02 +01:00
Orkun Tokdemir
c074f5c81e Autogen: Revert "AUTO*_EXECUTABLE: add support for per-config values"
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
2023-10-13 14:16:26 -04:00
Orkun Tokdemir
bac468ddfd AutoGen: Fix regression in timestamps on multi-config generators
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
2023-09-26 11:54:26 -04:00
Orkun Tokdemir
fddd0f0443 Autogen: AUTO*_EXECUTABLE: add support for per-config values
* 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
2023-09-13 18:23:56 +02:00
Orkun Tokdemir
cac2e029f0 cmQtAutoGenInitializer: Define CrossConfig variable 2023-09-13 15:59:54 +02:00
Orkun Tokdemir
d4889361f0 cmQtAutoGenInitializer: Reduce string copies 2023-09-13 15:58:47 +02:00
Orkun Tokdemir
0bf49d5579 cmQtAutoGenInitializer: Remove no-op call 2023-09-13 15:58:47 +02:00
Orkun Tokdemir
94c4c1cb28 cmQtAutoGenInitializer: Improve Const-Correctness 2023-09-13 15:58:47 +02:00
Orkun Tokdemir
6d54c36859 Autogen: Fix typo 2023-09-13 15:58:47 +02:00
Orkun Tokdemir
ebc9e448b3 Autogen: Add depfile support for Makefiles
Fixes: #21677
2023-09-11 14:51:58 +02:00
Orkun Tokdemir
1f4b374d6e cmQtAutoGenInitializer: Reduce string copies 2023-05-31 13:04:49 -04:00
Orkun Tokdemir
b6f66b445a cmQtAutoGenInitializer: Remove no-op calls 2023-05-31 13:03:37 -04:00
Orkun Tokdemir
55d93bdabf cmQtAutoGenInitializer: Improve const correctness 2023-05-31 13:02:45 -04:00
Orkun Tokdemir
2bb3d9b644 Autogen: Fix multi-config generated file issue
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
2023-05-27 12:55:21 +02:00
Orkun Tokdemir
3bd605f3d0 Autogen: Optimize cmake_autogen execution for CROSS_CONFIG usage
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.
2023-05-26 16:11:12 +02:00
Orkun Tokdemir
f2f21c5752 Improve Const Correctness 2023-05-26 14:15:24 +02:00