Commit Graph

138 Commits

Author SHA1 Message Date
Brad King
8832f78dd6 IWYU: Update for Debian 13 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 13.  Some patterns:

* Types named in virtual `override` signatures no longer require
  includes since the overridden signature already names them.

* A function argument's type needs to be included even if its constructor
  is called only by implicit conversion.  For example, constructing a
  `std::function` from a lambda now requires `<functional>`.

* Some prior mysterious `<type_traits>` inclusions are no longer required.
2025-11-12 14:54:35 -05:00
Brad King
2a14338676 Merge branch 'backport-genex-refactor' into genex-refactor 2025-09-21 20:22:24 -04:00
Brad King
1735b0d147 GenEx: Construct cmGeneratorExpressionDAGChecker with full evaluation context
Extend commit e8010b67c7 (cmGeneratorExpressionDAGChecker: Make local
generator available in constructor, 2024-04-25, v3.30.0-rc1~172^2~6) and
commit 633afa0b2e (cmGeneratorExpressionDAGChecker: Make config name
available in constructor, 2024-05-08, v3.30.0-rc1~82^2~2) to make the
full evaluation context available in the constructor.
2025-09-21 20:20:03 -04:00
Brad King
d4d204382f GenEx: Collect evaluation arguments into local Context structures 2025-09-21 20:17:16 -04:00
Eduard Voronkin
01147454e7 FASTBuild: Add generator
Fixes: #15294
2025-08-26 14:29:01 -07:00
Vito Gamberini
baa74ed677 clang-tidy: Use cleaner path to export-fixes file with Ninja
The clang-tidy "export-fixes" flag was using unconverted Ninja paths due
to a flipped boolean check from commit 993dde925f (TargetGenerator:
Factor out generation of code check rules, 2023-05-12,
v3.27.0-rc1~84^2~2).
2025-07-15 10:46:10 -04:00
Ben Boeckel
b82a74d918 generators: use GetSupportDirectory() in more places 2025-05-23 11:39:53 +02:00
Felipe Torrezan
c7d2a17253 IAR: Add support for C-STAT static analysis
The IAR platform offers an integrated static analysis tool named
IAR C-STAT.

Closes: #26844
2025-04-09 12:01:02 -04:00
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
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
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
633afa0b2e cmGeneratorExpressionDAGChecker: Make config name available in constructor 2024-05-21 09:22:51 -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
Ben Boeckel
7cd0adab1b cmCommonTargetGenerator: use modules from linked object-referenced targets
Fortran modules provided by objects added as linked items via
`$<TARGET_OBJECTS>` should also be considered as "linked targets" for
collation purposes. As C++ modules have their own visibility rules
through their `FILE_SET` feature, do not expose these for C++ module
collation.
2023-11-23 14:26:31 -05:00
Ben Boeckel
06df59b930 cmCommonTargetGenerator: return forward linked target dirs too
This will be used for module forwarding in order to support
`$<TARGET_OBJECTS>` usage in source and link libraries calls.
2023-11-21 09:44:39 -05:00
Ben Boeckel
515ca5fcd1 cmCommonTargetGenerator: use modules from object-referenced targets
Fortran modules provided by objects added as sources via
`$<TARGET_OBJECTS>` should also be considered as "linked targets" for
collation purposes. As C++ modules have their own visibility rules
through their `FILE_SET` feature, do not expose these for C++ module
collation.
2023-11-21 09:42:58 -05:00
Brad King
d7988ff6b8 Merge branch 'backport-target-objects' into target-objects 2023-11-14 15:42:07 -05:00
Brad King
1814853081 cmCommonTargetGenerator: Drop unused local variable 2023-11-14 15:40:33 -05:00
Brad King
50fdaf8f1f cmComputeLinkInformation: Track targets named by TARGET_OBJECTS sources
Since commit b6a5382217 (Ninja: depend on language module information
files directly, 2023-02-10, v3.27.0-rc1~502^2), the return value of
`cmCommonTargetGenerator::GetLinkedTargetDirectories` must account for
linked object libraries because they may provide modules (#25112).
These were added by commit b665966933 (cmComputeLinkInformation: track
OBJECT library dependencies, 2023-07-22, v3.27.1~5^2).  However, targets
named by `$<TARGET_OBJECTS:...>` sources are also needed (#25365).

The latter were added by commit 22da18b995 (Fortran: Restore support for
TARGET_OBJECTS providing modules, 2023-10-27, v3.28.0-rc4~9^2) and
commit 035302b7e3 (cmComputeLinkDepends: also copy the target from
object link items, 2023-10-27, v3.28.0-rc4~9^2~2).  However, their
approach added link entries not actually specified by projects.  It also
incorrectly re-used `cmComputeLinkDepends::AddLinkObject` for object
library targets when it is meant for their individual object files.
These problems caused additional regressions (#25417).  Revert the
implementation parts of those commits and leave behind an assertion and
comment to help avoid the mistake in the future.  Instead, track targets
named by `$<TARGET_OBJECTS:...>` sources with a dedicated member.

Issue: #25112
Issue: #25365
Fixes: #25417
Co-authored-by: Ben Boeckel <ben.boeckel@kitware.com>
2023-11-14 14:50:08 -05:00
Brad King
0e26bd334d cmCommonTargetGenerator: Factor out GetLinkedTargetDirectories loop body
Re-use the body in multiple loops instead of allocating to combine them.
2023-11-14 13:50:13 -05:00
Brad King
7831781155 Merge topic 'lint-genex-empty'
80df7b1745 Linting: Fix empty evaluated genex

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8833
2023-09-26 09:30:10 -04:00
Orkun Tokdemir
80df7b1745 Linting: Fix empty evaluated genex
Update logic added by commit 099934e313 (Add generator expression
support to static code analysis hooks, 2023-03-24, v3.27.0-rc1~261^2),
and preserved by commit 993dde925f (TargetGenerator: Factor out
generation of code check rules, 2023-05-12, v3.27.0-rc1~84^2~2), to
handle a generator expression that evaluates to the empty string.

If `<LANG>_CPPCHECK`, `<LANG>_CPPLINT`, `<LANG>_CLANG_TIDY`, or
`<LANG>_INCLUDE_WHAT_YOU_USE` are empty after evaluating generator
expressions, do not run their lints.

Fixes: #25265
2023-09-25 09:16:33 -04:00
Ben Boeckel
2c7acd34e2 cmComputeLinkInformation: add OBJECT libraries as link items
This completes the transition started in commit b665966933
(cmComputeLinkInformation: track OBJECT library dependencies,
2023-07-22).
2023-08-01 10:06:02 -04:00
Brad King
241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Ben Boeckel
b665966933 cmComputeLinkInformation: track OBJECT library dependencies
In commit b6a5382217 (Ninja: depend on language module information files
directly, 2023-02-10), introduced via !8197, language-specific module
information files (`CMakeFiles/<target>.dir/<lang>Modules.json`) files
were added as real dependencies to the dyndep collation steps.
Previously, the behavior was to inform the collator of all possible
targets and search for the files manually ignoring those which did not
exist with ordering enforced by depending on the linker output of all
dependent targets. This behavior could lead to stale information being
used (e.g., if a target stops providing any targets) and also did not
reliably build everything needed on rebuilds. Afterwards, the internal
computation changed the dependency from all possible targets to an exact
set of "these targets might have modules" query, however one that did
not include `OBJECT` libraries since do not have `LinkEntry` items
internally (their objects are instead treated as source files).

As a stopgap measure, track `OBJECT` libraries in a separate list and
query them explicitly when gathering targets which may have interesting
information. Future work can add `LinkEntry` items to represent these
targets once all `LinkEntry` consumers have been audited to make sure
they are not surprised by any `OBJECT` library entries.

Fixes: #25112
2023-07-22 07:12:43 -04:00
Brad King
93ee2b369c Source: Fix -Wdangling-reference warnings exposed by gcc 13 2023-05-22 17:14:54 -04:00
Orkun Tokdemir
993dde925f TargetGenerator: Factor out generation of code check rules
De-duplicate code check rule generation in Ninja and Makefile generators
by moving their implementation to `cmCommonTargetGenerator`.

Previously Ninja was generating code check rules per language.
It was changed to generate code check rules for each source file.
2023-05-16 10:46:35 -04:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Brad King
367aa65a9f Merge topic 'module-depends-static-lib-cycle'
01d7860fdb Ninja,Makefile: Restore Fortran module scanning in static library cycle
846baa7c5b cmGlobalGenerator: Factor out helper to check target ordering

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8363
2023-03-27 09:51:59 -04:00
Brad King
01d7860fdb Ninja,Makefile: Restore Fortran module scanning in static library cycle
Since

* commit eed295fd8a (cmGlobalNinjaGenerator: require that dependency info
                     files work, 2023-02-01, v3.26.0-rc1~1^2~1), and
* commit 13810dee17 (cmDependsFortran: require that dependency info files
                     work, 2023-02-01, v3.26.0-rc1~1^2),

the Ninja and Makefile generators' module dependency scanning requires
that scanning results from from linked targets is available before
scanning the current target.  In the case of a static library cycle,
we cannot expect this information from other static libraries in the
cycle.  Previously we supported cyclic cases at the cost of silently
ignoring missing information.

We already compute a global order of targets that respects all
`add_dependencies`, but may break `target_link_libraries` dependencies
that occur in a static library cycle.  Use this order to filter the
linked targets so we only expect scanning results to be available from
those targets that build before the current target.

This approach is sufficient to support module dependency scanning in
static library cycles as long as module dependencies do not cross
between two libraries in the same cycle.

Fixes: #24631
2023-03-24 15:57:52 -04:00
Marc Chevrier
ede33f30cf Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
2023-03-01 12:23:28 +01:00
Marc Chevrier
fcbd723a50 Enhance support functions
* Avoid duplicate definiitions for IsExecutableWithExports, etc...
* Add helper IsApple()
2023-02-28 14:24:03 +01:00
Ben Boeckel
bde9d4ad01 cmCommonTargetGenerator: also consider synthetic targets 2023-02-14 12:34:46 -05:00
Brad King
c3210aab46 Merge topic 'lang-linker-launcher-genex'
33e27f6ca6 <LANG>_LINKER_LAUNCHER: Allow generator expressions
84ada0b0c9 <LANG>_COMPILER_LAUNCHER: Expand subset of genexes that can be evaluated

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8152
2023-02-03 10:00:49 -05:00
Kyle Edwards
33e27f6ca6 <LANG>_LINKER_LAUNCHER: Allow generator expressions 2023-02-02 11:58:56 -05:00
Ben Boeckel
837f7c113a cmCommonTargetGenerator: classify linked target directories by language
These directories are used to direct collators for Fortran and C++
modules to consume dependent module information to properly collate.
However, the consumption of these files merely checks for existence of
the file, not whether they are actually needed anymore.

The problem arises when a target has Fortran or C++ modules at point A,
a build occurs populating this file, and then the target is updated to
no longer have potential modules. The `DependInfo.make` (for
`Makefiles`) or `<LANG>DependInfo.json` (for `Ninja`) files still exist
as they are never guaranteed to be cleaned up. This can introduce stale
information to the build which may cause a false-positive compilation if
a module file happens to still exist and gets found this way.

Instead, query the `linked-target-dirs` using the language in question
and only add the directory if it contains potential sources for modules
coming from the language in question.
2023-01-31 22:34:29 -05:00
Ben Boeckel
a8115deebe cmCommonTargetGenerator: fix linked target directory for multi-config builds
Without this, `Ninja Multi-Config` generators were not getting the right
directory to look for `<LANG>Modules.json` files for module information.
2022-06-14 19:27:30 -04:00
Brad King
39dba8a244 cmLocalGenerator: Adopt AppendModuleDefinitionFlag method
Migrate from `cmCommonTargetGenerator::AddModuleDefinitionFlag`.
2022-05-31 15:40:35 -04:00
Robert Maynard
627ef4c1d0 Provide guidance when trying to use non-enabled language
Fixes #23463
2022-05-04 09:33:35 -04:00
Peter Hill
6b4885b58b Ninja: Avoid preprocessing twice with explicit Fortran_PREPROCESS
Fix spurious warnings from gfortran+Ninja for preprocessing.

Fixes: #23248
2022-02-24 12:54:46 -05:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Thomas Bernard
b73857561f Clang: embed windows manifests with GNU interface
Solves: #22611
2021-09-17 00:35:32 +02:00
Marc Chevrier
791337f181 Refactor: cmCommonTargetGenerator::GetFeature returns cmProp 2021-08-09 17:28:31 +02:00
Bobby D Reynolds
ae108418ae Launchers: Support setting linker launchers
Fixes: #18316
2021-05-28 12:28:43 -04:00
Brad King
1879f1bcbc cmLocalCommonGenerator: Factor out relative path conversion helper 2021-05-13 12:47:25 -04:00
Oleksandr Koval
209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Vitaly Stakhovsky
18726ad634 GetFeature(): return cmProp 2020-07-11 14:03:03 -04:00