Commit Graph

592 Commits

Author SHA1 Message Date
Ben Boeckel 366b25e62e ast-grep: simplify cmHasLiteral{Suf,Pre}fix with char literals 2025-11-20 12:14:14 -05:00
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
Alex Turbov 8de02a14c8 ci(pre-commit): version bump typos hook plus fix found typos 2025-10-23 21:14:25 +04:00
Martin Duffy 97adbc91fa instrumentation: Move target data into content files
Create a single place to store target data to prevent duplication.
This moves `targetType` and `targetLabels` out of the snippet files
and into a target map in the `cmakeContent` file referenced by each
snippet.

Fixes: #27244
2025-10-02 09:28:20 -04:00
Alex Turbov f100769d72 Add SKIP_LINTING target property and CMAKE_SKIP_LINTING variable
These offer target-wide settings to disable lints.

Closes: #27191
2025-09-09 09:56:35 -04:00
John Parent 851e07fda3 Ninja: support short object directories 2025-07-29 08:06:30 -04:00
Ben Boeckel dfba904178 Ninja: populate the TARGET_SUPPORT_DIR replacement variable 2025-07-28 12:01:27 -04:00
Bastien Montagne 3a9d56d2c7 Ninja: Add support for per-source JOB_POOL_COMPILE property
This commit allows to override a global or target-wide 'job pool'
property on a per-source basis.

It modifies the Ninja generator to first look into the source's
properties, and only use the target properties as a fallback.

The new `source` parameter to
`cmNinjaTargetGenerator::addPoolNinjaVariable` may be null, e.g. when
the function is called in context where there is no source (e.g. a
linking task).

Closes: #23994
2025-07-16 21:16:24 +02:00
Ben Boeckel a16566105b cmNinjaTargetGenerator: fix DependInfo.json generation location
Commit aafd771529 (cmNinjaTargetGenerator: use `GetObjectFileDir` where
possible, 2025-05-21) from !10812 accidentally converted the
`GetTargetDependInfoPath` from an always-absolute path to a
relative-for-ninja path. This works fine as everything ended up doing
`ConvertToNinjaPath` as necessary *except* the code which actually wrote
the file. That needs an absolute path in order to generate it in the
correct location.

Fixes: #26983
2025-06-09 21:58:32 +02:00
Ben Boeckel b82a74d918 generators: use GetSupportDirectory() in more places 2025-05-23 11:39:53 +02:00
Ben Boeckel aafd771529 cmNinjaTargetGenerator: use GetObjectFileDir where possible
Lots of code simplification.
2025-05-22 17:02:53 +02:00
Ben Boeckel ec85753502 cmNinjaTargetGenerator: convert linked target dirs to ninja paths 2025-05-22 17:02:53 +02:00
Ben Boeckel 557c44b93e cmStrCat: use character literals where possible
Found and replaced using the `cmstrcat-to-char-literal` rule for
`ast-grep`.
2025-05-15 19:12:04 +02:00
Ben Boeckel 23779057fd cmStrCat: combine neighboring arguments where possible
Found using the `cmstrcat-adjacent-literals` rule for `ast-grep`.
2025-05-15 19:11:41 +02: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
Martin Duffy 9689155a05 instrumentation: Add Config value to snippet data 2025-02-09 12:29:09 -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
Martin Duffy 9d34069ca8 instrumentation: Add targetLabels field to link snippets
Adds a new data field `targetLabels` to link snippets which contains a list of
text labels from the LABELS target property.
2025-01-17 11:07:30 -05:00
Alex Turbov bc8621d999 Fix: A lot of typos in code found by typos
Yet another great code spellchecker: https://github.com/crate-ci/typos/

(Will be added later as a `pre-commit` hook)
2025-01-12 18:49:34 +04:00
Alex Turbov bdece1c754 Refactor: Optimize ostream::operator<<() calls for some generators 2024-12-11 19:40:41 +04:00
Brad King 659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Marc Chevrier 2bd4c06c26 Refactoring cmRulePlaceHolderExpander: propagate cmBuildStep information 2024-11-04 17:08:02 +01:00
Winfried Auner 75e4cd8d18 Ninja: Fix escaping of paths with spaces for Swift tooling
If a path inside a project contains spaces, the generated Ninja
definitions previously contained superfluous quotes.

Fixes: #26404
2024-11-01 08:59:32 -04:00
Sander Cox ad10c31845 Ninja: Fix object path quoting in compilation database
For the compile_commands.json file the object file path needs to
be escaped as well, just like the source path. Otherwise tools like
clangd might not be able to parse the commandline properly.
2024-10-21 23:05:15 +02:00
Brad King b11323f1e4 Ninja: Fix depfile binding with spaces in path
In build statements we use a single `DEP_FILE = ...` binding that is
shared between `depfile = $DEP_FILE` and `command = ... $DEP_FILE ...`
bindings in the corresponding rule.  In cases that the command's shell
argument needs quoting, add a separate `depfile = ...` binding to the
build statement to express the depfile path without quoting.  Otherwise
`ninja` tries to open a file path that contains literal quotes.

Fixes: #26287
2024-09-13 09:04:32 -04:00
Brad King ad66be9943 cmNinjaTargetGenerator: Factor out helper to add depfile bindings 2024-09-12 12:24:48 -04:00
Brad King 269c3a13c8 cmNinjaTargetGenerator: Reduce DEP_FILE binding duplication 2024-09-12 12:24:48 -04:00
Ben Boeckel 84bc710d84 cmGlobalGenerator: generate build database files for targets 2024-08-27 12:37:36 -04:00
Brad King 9f8afacb3e cmGlobalNinjaGenerator: Reuse local generator caching of config list 2024-06-21 10:59:30 -04:00
Dave Abrahams 5bb7f8a4dd Swift: Use per-config module file locations in multi-config generators
Place `.swiftmodule` files a subdirectory named after the configuration.

Fixes: #25864
Fixes: #25997

- Swift/RunCMakeTest.cmake:
  - CMP0157-OLD was enabled for Xcode, where it works.
  - A test was added that verifies .swiftmodule's are generated into
    separate directories with multi-config generators.

- Tests/SwiftOnly/CMakeLists.txt: tests were added that validate that
  cross-subdirectory module dependencies (via target_link_libraries)
  work.
2024-05-24 15:23:41 -07:00
Dave Abrahams b2e042d77a cmGeneratorTarget: Adopt Swift-related methods from the Ninja generator
They will see more use as Swift bugs are fixed in the
Ninja Multi-Config generator.
2024-05-24 15:20:08 -07:00
Brad King ef006ebd9b PCH: Use per-arch .pch files only when building multiple Apple architectures
Since commit f593b354da (PCH: Add support for multi architecture iOS
projects, 2020-04-02, v3.18.0-rc1~414^2) we use per-arch .pch files
even when compiling for just the host architecture on macOS arm64.
This breaks with compilers that do not support `-Xarch_` flags, such
as GCC.  Avoid using per-arch .pch files in single-architecture builds.

Fixes: #25514
Issue: #20497
2024-05-01 12:43:39 -04:00
Brad King 99bfb430ee cmNinjaTargetGenerator: Remove unused Apple architecture list 2024-05-01 12:27:16 -04:00
Jeremy Day c5ef7fac23 Swift/Ninja: Add description to Swift object build steps
By default, Ninja displays the full build command for the object which
is very verbose. Warnings are often lost in the noise, and compile
errors take some searching to find. If a build step fails, Ninja will
still print out the full build command, so there's no loss of useful
information.

Fixes: #25853
2024-04-23 10:29:08 -07:00
Evan Wilde 579472d877 Swift: Ninja: Remove module dependency for executables
We shouldn't include the swiftmodule in the ninja dependency graph
unless that target emits a swiftmodule.

Fixes: #25869
2024-04-08 18:07:13 -07:00
Brad King 0287208bbf Merge topic 'ninja-fortran-include' into release-3.29
36dc8d6d50 Ninja: Fix Fortran module deps in files INCLUDEd by preprocessed sources

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9351
2024-03-20 09:55:47 -04:00
Brad King 36dc8d6d50 Ninja: Fix Fortran module deps in files INCLUDEd by preprocessed sources
If a preprocessed source also uses the Fortran `INCLUDE` directive,
search the original source file's directory.

Fixes: #25792
2024-03-19 07:56:13 -04:00
Evan Wilde f292e28b84 Swift: Ninja: Pass module name to all swift builds
Executables that don't export a public API should not emit a
swiftmodule, but the swift modulename is observable from within the
program, so we should still set the module name on executable builds.

Fixes: #25710
2024-02-23 11:12:05 -05:00
Brad King 273463aaa9 Merge topic 'cxxmodules-collation-restat' into release-3.29
a7424b636b Ninja: make the collator rule use `restat = 1`
e24eecfc33 Tests/CXXModules: add a test to ensure that `restat` works for collation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9259
2024-02-16 09:32:15 -05:00
Brad King 00fcb1dc81 Merge topic 'cxxmodules-visibility-change-rebuild' into release-3.29
60a8736378 cmNinjaTargetGenerator: scanning depends on the module metadata
52036ce090 Tests/CXXModules: test that objects depend on dependent modules json files
9a45c9fbd5 cmNinjaTargetGenerator: use `emplace_back` for scanning deps

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9247
2024-02-16 09:26:49 -05:00
Brad King 97132612f6 Merge topic 'cxxmodules-depend-on-modmap-file' into release-3.29
363300ace5 cxxmodules: depend on the modmap contents
940628d48d Tests/CXXModules: test that objects depend on their modmap files
681ee92030 Tests/CXXModules: support testing rebuild conditions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9248
2024-02-16 09:20:52 -05:00
Ben Boeckel a7424b636b Ninja: make the collator rule use restat = 1
This avoids rebuilds when the module metadata does not change.
2024-02-14 23:01:25 -05:00
Ben Boeckel 60a8736378 cmNinjaTargetGenerator: scanning depends on the module metadata
Fixes: #25531
2024-02-14 22:36:37 -05:00
Ben Boeckel 9a45c9fbd5 cmNinjaTargetGenerator: use emplace_back for scanning deps 2024-02-14 20:38:06 -05:00
Ben Boeckel 363300ace5 cxxmodules: depend on the modmap contents
If the modmap changes, we need to recompile. It is not just a file that
needs to exist to compile.

Fixes: #25511
2024-02-14 20:36:47 -05:00
Brad King eee631bb8a Merge topic 'ewilde/swift-escapism'
9950a69f26 Swift/Ninja: Fix compile commands output file path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9150
2024-01-16 11:44:58 -05:00
Brad King e315d7cb19 Merge topic 'swift-sources-in-resp-file'
b767917ebb Swift/Ninja: Include sources in response file

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9143
2024-01-12 08:53:10 -05:00
Evan Wilde 9950a69f26 Swift/Ninja: Fix compile commands output file path
The exported compile commands did not use the proper file path separator
for Windows in the output field for Swift files. This patch adds the
appropriate filepath fix-ups to the output-field.

Fixes: #25580
2024-01-11 20:31:40 -08:00
Evan Wilde b767917ebb Swift/Ninja: Include sources in response file
Unlike C/C++, Swift compiles all sources in a module at once. This can
quickly overwhelm the commandline length limit on Windows, so it is
useful to place the source files in the response file.

Issue: #25572
2024-01-10 16:08:16 -08:00
Saleem Abdulrasool 9e829779f2 Swift: preserve -static for static library swiftmodules
The `-static` is important for the emission of the module as it is
serialized into the swiftmodule which then is used by the Swift frontend
to decide how to link to the symbol (via the GOT or not, or the IAT on
Windows). This repairs building static libraries with Swift on Windows.
2024-01-09 09:13:34 -08:00