Commit Graph

336 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
deb70f536e Merge topic 'cmake-init'
40b093649b cmake: Avoid calling GetCMakeListFile with empty directory
f6b3ba5f55 CMP0198: Maintain CMAKE_PARENT_LIST_FILE only when configuring projects
3593aa59ef cmake: Replace working mode with role
accfa7fa81 cmake: Infer command failure action from role
e290d4f2a3 cmake: Infer command set from role
bfaaec6179 cmake --workflow: Convert implementation to internal role
ea5d04975e cmake --build: Convert implementation to internal role
0b83750e14 cmake: Clarify name of role of internal instances
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11395
2025-11-10 09:13:42 -05:00
Brad King
06b3095df7 Merge topic 'process-timeout-short'
6ec2c51f0c execute_process: Restore support for short timeouts

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11399
2025-11-10 09:08:41 -05:00
Brad King
6ec2c51f0c execute_process: Restore support for short timeouts
Since commit 5420639a8d (cmExecuteProcessCommand: Replace cmsysProcess
with cmUVProcessChain, 2023-06-01, v3.28.0-rc1~138^2~8) we've
occasionally observed immediate timeouts on processes that take longer
than the timeout to start, even though we only start the timer after the
child processes start.  The problem is that:

* `uv_loop_init` initializes `uv_loop_t`'s cached "now" time.
* Starting processes takes time but does not update the "now" time.
* `uv_timer_start` computes expiry relative the cached "now" time,
  so short timers may be expired as soon as they are started.
* `uv_run` invokes expired timer callbacks before polling for I/O
  or process completion, so we "timeout" immediately.

Fix this by updating the cached "now" time via `uv_update_time` just
before starting timers.  This is needed only for timers that start
before the `uv_run` event loop.  Update our `uv_timer_ptr` wrapper
to make all callers consider the choice when calling `start()`.
2025-11-09 09:13:43 -05:00
Brad King
e290d4f2a3 cmake: Infer command set from role 2025-11-07 09:35:54 -05:00
Brad King
0b83750e14 cmake: Clarify name of role of internal instances
These instances do not run arbitrary cmake language code.
2025-11-07 09:35:54 -05:00
Brad King
0aab75bf0e cmake: Clarify name of enum backing CMAKE_ROLE property 2025-11-07 09:35:53 -05:00
Brad King
9e36f22684 cmake: Clarify name of enum identifying set of commands added 2025-11-07 09:35:53 -05:00
Brad King
df83179047 Merge topic 'sbom_model'
0653620033 cmSbom: Add SPDX object model and serializers
985b0f5bcf CMake C++11 Compatibility: Add more type_traits from C++14 and C++17

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11231
2025-10-25 09:13:43 -04:00
Taylor Sasser
0653620033 cmSbom: Add SPDX object model and serializers
Adds definitions for representing software bill of materials (SBOM) information
and generating SPDX SBOMs.

Issue: #26719
Issue: #27001
2025-10-24 13:59:01 -04:00
Richard
41be8cb44a FileAPI: Fix paths relative to root directory
We normalize directory paths to not end in `/`.  However, a root
directory path always ends in `/`.  Avoid removing the first character
after it.

Fixes: #27308
2025-10-22 09:25:39 -04:00
Brad King
6b5877a176 libarchive: Backport "parse_date: handle dates in 2038 and beyond"
Backport libarchive commit `2d987e725f` (parse_date: handle dates in
2038 and beyond if time_t is big enough, 2025-09-26).

Add a cmake-specific test case.

Fixes: #27263
2025-09-30 09:36:08 -04:00
Sergiu Deitsch
7040406f86 cmListFileLexer: Do not require null-terminated input 2025-09-12 18:28:55 +02:00
Daniel Pfeifer
b1fdab3cc1 source: Pass small and trivially copyable types by value 2025-08-01 09:56:00 -04:00
Daniel Pfeifer
99c10afc26 source: Pass trivial dap::*Event by value 2025-08-01 09:55:59 -04:00
Taylor Sasser
aaeffdfe6b cmArgumentParser: Refactor to allow for nested parsers 2025-07-23 09:42:05 -04:00
Brad King
f143b8a623 Merge topic 'keyword-project-name-fix'
a38e594340 project: fix keyword argument as project name
7238c8c999 ArgumentParser: implement HasKeyword helper

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10935
2025-07-09 09:44:50 -04:00
Vito Gamberini
7238c8c999 ArgumentParser: implement HasKeyword helper 2025-07-08 17:44:07 -04:00
Vito Gamberini
be4a942d7f SBOM(SPDX): Implement graph components and serializer 2025-06-19 10:44:27 -04:00
Matthew Woehlke
5eec48ee40 cmArgumentParser: Simplify assignment of marker types
Explicitly allow argument markers to be assigned. Make use of this in
parsing. This simplifies working with these types, by allowing them to
be assigned from the underlying types using simple `a = b` syntax,
rather than requiring gymnastics to access the underlying assignment
operations. It also makes assignment more consistent with
initialization.
2025-05-30 11:10:41 -04:00
Brad King
6be0c6d26a Merge topic 'astgrep-cmstrcat'
557c44b93e cmStrCat: use character literals where possible
23779057fd cmStrCat: combine neighboring arguments where possible
483d13daf4 ast-grep: add a rule to turn strings into characters
61743471d9 ast-grep: add a rule to find adjacent string literals in cmStrCat calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10790
2025-05-22 08:47:15 -04:00
Brad King
329d755dbd StdIo: Add a Terminal abstraction to print color text
Abstract over VT100 sequences and Windows Console text attributes.

This will replace KWSys Terminal, which does not integrate with C++
streams.

Issue: #26924
2025-05-19 08:16:56 -04:00
Brad King
2647d97ab7 cmext/enum_set: Fix static default construction on older AppleClang versions
AppleClang 8.0 and below do not understand a `= default;` constructor
in static constant default initialization, but do accept `{}`.
2025-05-16 15:03:32 -04: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
Brad King
f9f1f9a8cd StdIo: Add a Windows Console adaptor for cin, cout, and cerr
On Windows, the only reliable way to read/write Unicode text from/to a
Console is to use `ReadConsoleW` and `WriteConsoleW` and convert from/to
wide-character encoding.  When `cin`, `cout`, and/or `cerr` are attached
to a Windows Console, use a custom C++ `streambuf` to handle the I/O.

This will replace KWSys ConsoleBuf, whose implementation is more complex
to support narrow output streams on Windows non-UTF-8 narrow encodings.
We only need to support UTF-8.

Issue: #26924
2025-05-13 10:35:47 -04:00
Brad King
d6a1ff59f1 StdIo: Provide metadata about stdin, stdout, stderr streams
Detect the kind of terminal to which they are attached, if any.

Issue: #26924
2025-05-11 09:13:16 -04:00
Brad King
cef4676d3a StdIo: Factor out helper to initialize stdin, stdout, and stderr
Move logic from commit c85524a94a (Ensure stdin, stdout, and stderr pipes
are always open, 2019-05-02, v3.15.0-rc1~171^2) and commit 96010cc968
(Ensure stdin, stdout, stderr FILE streams are open on Windows, 2024-01-24,
v3.29.0-rc1~65^2) to a dedicated source.  Expose it through an `Init` class
constructor to make it optionally available during static initialization.

Issue: #26924
2025-05-08 13:39:48 -04:00
Brad King
3f8ad3e894 Tests: Simplify implementation of execute_process encoding test executable
Replace use of KWSys ConsoleBuf with direct encoding conversion calls.
2025-04-17 19:53:45 -04:00
Vito Gamberini
df870e17f5 cmArgumentParser: Implement trailing positional args 2025-04-16 14:15:48 -04:00
Brad King
2604f5d8b3 Merge topic 'json-errors-filename'
f134468a98 JSON: Improve JSON error message formatting

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10463
2025-03-14 12:17:02 -04:00
Martin Duffy
f134468a98 JSON: Improve JSON error message formatting
This improves the output of JSON-related error messages. It adds the filename to
the output and excludes the column number.

This is particularly useful when there are multiple JSON files being read that
could be responsible for an error, ie CMakePresets.json and
CMakeUserPresets.json, or multiple instrumentation queries.

Issue: #26717
2025-03-13 10:44:31 -04:00
Brad King
cd38131f31 Merge topic 'path-resolver'
8dfc725cdb PathResolver: Add mode to collapse paths naively and look up on-disk case
75913fe430 PathResolver: Document in comments the on-disk case lookup on macOS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10438
2025-03-09 10:48:46 -04:00
Brad King
8dfc725cdb PathResolver: Add mode to collapse paths naively and look up on-disk case
In CMake 3.31 and below, `CollapseFullPath` did this on Windows.  KWSys
has since stopped looking up the on-disk case in `CollapseFullPath` to
avoid disk access when most callers only need an in-memory operation.
We currently call `GetActualCaseForPath` explicitly when needed.

Add a mode to `cm::PathResolver` to combine these operations and cache
disk access behind the `System::ReadName` callback.  We will use this to
restore the way CMake 3.31 and below normalized input paths on Windows.

Issue: #26750
Issue: #20214
2025-03-07 18:22:46 -05: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
Kitware Robot
de273b2e11 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 09:56:07 -05:00
Brad King
f9e51b61cd Merge topic 'enum_set-enhancements'
4d48958965 enum_set enhancements, step 3

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10335
2025-02-15 07:31:40 -05:00
Brad King
8845d33292 Merge topic 'regex'
5d039f3be3 regex: Match ^ at most once in repeated searches

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10221
2025-02-14 09:38:04 -05:00
Marc Chevrier
4d48958965 enum_set enhancements, step 3 2025-02-14 10:38:34 +01:00
Nikita Nemkin
5d039f3be3 regex: Match ^ at most once in repeated searches
When doing successive matches, track the input start and current search
start positions separately to prevent the `^` anchor from matching in
the middle of the string.  Add policy CMP0186 to provide compatibility.

Issue: #26629
Fixes: #16899
2025-02-13 20:00:02 +05:00
Brad King
ab8b94986d Tests: Fix memory leak in CMakeLib.testUVPatches
In commit f189e64126 (Tests: Add cases covering our mkdtemp code paths,
2025-02-07) we forgot to close the libuv default loop.
2025-02-11 07:57:42 -05:00
Brad King
f189e64126 Tests: Add cases covering our mkdtemp code paths
* `cmSystemTools::MakeTempDirectory` is our own code.

* `uv_fs_mkdtemp` requires patching to backport to platforms
  not supported by upstream libuv.
2025-02-09 13:29:38 -05:00
Brad King
b1e37ad8bb Tests: Port CMakeLib.testSystemTools to common infrastructure 2025-02-08 09:51:18 -05:00
Marc Chevrier
77ab2446d4 enum_set enhancements, step 2
* remove support of size computation based on "magic" enum element because
  Oracle SunPro compilers crash on it.
* enhance handling of enum_set with explicit size.
2025-01-31 19:14:36 +01:00
Marc Chevrier
35dafcb5a1 cmext/enum_set: add various enhancements to increase usability 2025-01-29 16:42:52 +01: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
Kitware Robot
b2ba64add9 Revise C++ coding style using clang-format-18
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  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.

Fixes: #26123
2025-01-23 11:43:06 -05:00
Brad King
a41b1d66cd Merge topic 'test-mingw-no-vs'
a62313b1dd Tests: Fix testing with MinGW without VS installed
a02b70a23f Tests: Forward tested CMake generator to more cases

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10170
2025-01-16 08:42:55 -05:00
Brad King
a02b70a23f Tests: Forward tested CMake generator to more cases 2025-01-15 08:21:31 -05:00
Alex Turbov
78e45c2db6 Style: Replace TABs with spaces for indentation in some files
Mark files that must use TABs to indent in the `.gitattributes`.
Use space instead of TABs in sources and some data/test files.
2025-01-12 18:49:25 +04:00
Brad King
8a2cdc6ada Merge topic 'normalize-input-paths'
08040ced86 cmake: Look up on-disk case of input paths on macOS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10020
2024-12-02 10:04:55 -05:00