Commit Graph
384 Commits
Author SHA1 Message Date
Marc Chevrier b53f05cd8c cmArgumentParser: enhance multi command management 2026-09-14 18:24:48 +02:00
Tyler Yankee fca1ecb8a3 cmStringAlgorithms: Add Levenshtein distance 2026-09-11 08:23:29 -04:00
Ben Boeckel 9ed206876f testRST: add test cases for anonymous hyperlinks
These links have two underscores after the ticks.
2026-09-04 20:02:31 -04:00
Brad King 9f73c35d67 Merge topic 'list-transform-shared-state'
3151f7824f cmList: Fix shared state across nested list(TRANSFORM) calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12390
2026-08-12 11:42:42 -04:00
Brad King 59b7fcc1f0 Merge topic 'update-libarchive'
e420259ecc libarchive: Restore compilation of archive_parse_date within CMakeLib
5b530ba347 libarchive: Set build options the way we need for CMake
dbcd6402c3 Utilities: Update hard-coded try_compile results for libarchive 3.8.9
357710687f Merge branch 'upstream-LibArchive' into update-libarchive
94ae161ab5 LibArchive 2026-07-28 (27cbc782)
46ccf27ae3 libarchive: Update script to get 3.8.9
16984b0124 ctest: Fix STOP_TIME for vendored archive_parse_date from libarchive 3.8.8+

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12398
2026-08-12 11:38:33 -04:00
Brad King 16984b0124 ctest: Fix STOP_TIME for vendored archive_parse_date from libarchive 3.8.8+
libarchive commit `422aae80ae` (Date parsing: reject date components
with numbers of more than 4 digits, 2026-05-07), backported to version
3.8.8 by libarchive commit `8cf7393f98` (Merge pull request `#3010`...,
2026-05-07, `v3.8.8~142`), disallows our non-standard hyphen-free date
format.  Convert to a standard format.
2026-08-11 12:10:59 -04:00
Mickaël Germain 3151f7824f cmList: Fix shared state across nested list(TRANSFORM) calls
The TRANSFORM action registry held one live action instance per action for
the whole process, and each instance carried per-call state: a raw Selector
pointer, REPLACE's helper, APPEND/PREPEND's operands.  That was harmless
while every action ran to completion uninterrupted, but commit c7af6e94d8
(list(TRANSFORM): Add PREDICATE selector, 2026-04-08, v4.4.0-rc1) added a
selector that runs a user function once per element, interleaved with the
transform.  User code reentering list(TRANSFORM) with the same action now
rebinds the shared instance mid-flight.  That produces silently wrong
results, and a use-after-free once any element is transformed after the
reentering one.  It needs no unusual code to hit: a predicate calling
find_package(Python) reaches list(TRANSFORM ... REPLACE) inside FindPython's
own module.

Make action objects immutable and per-call.  Operands and the selector become
constructor arguments, Initialize is deleted, and the registry becomes a
constexpr table of metadata with a MakeTransformAction factory.  The
InSelection guard, duplicated in all eight actions, moves into the base class.

This also closes a second hole in the same machinery.  TransformActionApply
overrode only the vector form of Initialize, so transform(APPLY, "f",
selector) dispatched to the empty two-argument virtual in the base, left
Selector null, and dereferenced it.  With no virtual Initialize left to
inherit, an APPLY action without a cmMakefile is no longer constructible, so
the throwing stub that guarded the vector form is no longer needed.

Close a third, from commit 651f82642c (Add APPLY action for list(TRANSFORM),
2026-04-08, v4.4.0-rc1): the cmMakefile overload performs APPLY
unconditionally but validated only the arity of the action passed to it.
APPEND, PREPEND and APPLY all take one argument, so transform(APPEND, "x",
makefile) passed validation and then silently ran APPLY, calling "x" as a
function instead of appending it.  Reject any action but APPLY up front.
That path is unreachable from CMake code, since HandleTransformCommand only
selects the overload for APPLY, and Tests/CMakeLib has no cmMakefile to drive
it with, so it carries no test.

Document the predicate's evaluation order while here.  It runs once per
element, immediately before that element would be transformed.  The manual
did not state the timing, which matters precisely because a predicate that
reenters list(TRANSFORM) observes the outer call mid-flight.

Fixes: #28031
2026-08-11 11:36:08 -04:00
Tom Osika 72ae7352d5 get_property: Refactor logic to shared function 2026-08-10 17:29:13 -04:00
Daksh Mamodiya e6482b840a fileapi: Fix dangling reply reference on case-insensitive filesystems
Reply file names embed the configuration name verbatim.  Reconfiguring
a build tree with a build type that differs from the previous one only
in case (e.g. Debug -> debug) makes CMake write a reply whose name also
differs only in case from the existing file.  On a case-insensitive
filesystem the write is skipped because the name already exists, but
RemoveOldReplyFiles compared on-disk names to the just-written names
textually and deleted the surviving file, leaving the reply index
citing a target or directory reply that no longer exists on disk.

Prune reply files by file identity via cmSystemTools::GetFileId instead
of by name, so an on-disk entry that aliases a reply we just wrote is
kept.  An entry whose identity cannot be obtained is retained rather
than deleted.

Fixes: #28022
2026-08-06 17:44:54 +02:00
Brad King 6fa0c6114b Merge topic 'fix-missing-rst-roles'
a9e89fec6d cmRST: Add missing roles

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12348
2026-07-30 11:52:27 -04:00
Matthew Woehlke afd937eb3e cmRST: Split parsing into two phases
Refactor cmRST to split parsing into two phases; one which processes
directives and collects lines to be output, and a second which performs
the actual output. In particular, this fixes substitutions not being
replaced when the definition appears after usage.

To facilitate this, refactor how replacement definitions are collected
so that content included via `toctree` has a separate replacement
context.

Also, record the length of the previously output line, so that when
headings are detected, we can reconstruct the markup to match the
(potentially changed by replacements) final length of the header text.
2026-07-29 15:04:59 -04:00
Matthew Woehlke a9e89fec6d cmRST: Add missing roles
Our Sphinx extensions recognize several roles that missed being added to
our internal C++ parser (`cmRST`). Update the latter with the missing
roles, bringing the two back in sync. This addresses several roles that
`cmRST` was previously leaving as inline markup that more appropriately
should be converted to literal text.
2026-07-29 15:00:40 -04:00
Daksh Mamodiya 79331d5865 CTest: Add Windows job server client
Use a named semaphore polled from the libuv event loop to share GNU Make
job slots on Windows. Cover token ordering, bounded draining, and
teardown, and document the new support.

Fixes: #27968
2026-07-20 16:40:11 +02:00
Matthew Woehlke a5a9ec9113 TargetTypes: Extract target-related types to dedicated header
Move some target related enumeration types from `cmStateTypes.h` to a
new header, as these really aren't "state" types. Also, make
`TargetType` a strongly-typed enumeration.
2026-07-01 14:44:11 -04:00
Mickaël Germain 4d86ef5e86 GenEx: add $<LIST:SORT,...,COMPARATOR,body> comparator
Add a COMPARATOR form to $<LIST:SORT> that orders the list by a caller-defined
rule: a <body> evaluated per comparison with the two elements bound to $<_0>
and $<_1>, yielding "1" when the first should sort before the second.  This
brings the custom ordering of list(SORT ... COMPARATOR) to generate time, so
elements can be ordered by target properties or any other generator expression.
CASE: and ORDER: still apply, while COMPARE: is rejected because the body
defines the ordering.

Fixes: #27892
2026-06-30 08:19:41 -07:00
Mickaël Germain e335872625 GenEx: generalize bound operands to a frame and add $<_1>
Allow a binding operation to bind more than one operand at once, exposed as
$<_0>, $<_1>, ....  A single value remains the common case, but the upcoming
SORT COMPARATOR must bind the two elements being compared, so the binding
becomes an indexed frame and $<_1> is added.  Referencing an index the active
binding does not provide is reported as an error.

Issue: #27892
2026-06-30 08:19:41 -07:00
Mickaël Germain 092edb6860 GenEx: add $<LIST:FILTER> PREDICATE filter and REGEX keyword
Let $<LIST:FILTER> select elements by an arbitrary condition: PREDICATE keeps or
drops each element according to a <body> evaluated with $<_0> bound,
complementing the existing regular-expression form.  Also accept an explicit
REGEX keyword before the pattern so the regex and predicate forms read
symmetrically; the bare pattern keeps working.

Issue: #27892
2026-06-23 21:31:49 -07:00
Mickaël Germain d2ad140ef9 GenEx: add PREDICATE selector to $<LIST:TRANSFORM>
Add a PREDICATE selector to $<LIST:TRANSFORM> that chooses which elements to
transform by evaluating a <body> per element (with $<_0> bound) and acting on
those for which it yields "1".  This selects by computed condition instead of
the fixed AT/FOR/REGEX positions, so any generator expression -- including
target queries -- can decide where an action applies.  It works with both the
canned actions and APPLY.

Issue: #27892
2026-06-23 21:31:20 -07:00
Brad King cd5a8dfa8e Merge topic 'genex-list-transform-apply'
0f6e8ded1d GenEx: add $<LIST:TRANSFORM,...,APPLY,body> action
c0a0b7fdd9 GenEx: add bound-operand binding mechanism and $<_0>
caa51f5689 GenEx: factor TRANSFORM selector parsing and selection

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12203
2026-06-23 10:17:50 -04:00
Mickaël Germain 0f6e8ded1d GenEx: add $<LIST:TRANSFORM,...,APPLY,body> action
Add an APPLY action to $<LIST:TRANSFORM> that evaluates an arbitrary <body>
once per selected element, with $<_0> bound to the element, so a list can be
mapped through any generator expression at generate time.  Unlike the
configure-time list(TRANSFORM ... APPLY <function>) command, the genex form has
no side effects and returns the body's value directly, and a list-valued result
expands into multiple elements.

The body evaluates in its own binding scope, so nested APPLY actions can shadow
$<_0>, and context-sensitive state it observes (such as target dependencies)
still propagates to the enclosing expression.  APPLY accepts the same
AT/FOR/REGEX selectors as the canned actions.

Issue: #27892
2026-06-21 18:05:53 -07:00
Mickaël Germain c0a0b7fdd9 GenEx: add bound-operand binding mechanism and $<_0>
Introduce "binding operations": generator expressions that evaluate a <body>
once for each value they supply, with $<_0> expanding to that value.  This is
the foundation the $<LIST:TRANSFORM,...,APPLY> action and the predicate
selectors build on, letting a <body> refer to the element being processed.

Using $<_0> outside a binding operation is reported as an error rather than
silently expanding to nothing.

Issue: #27892
2026-06-20 12:32:30 -07:00
Brad King 9b4a48e48d Merge topic 'pvs-fixes'
e2f4b9bedc pvs-studio: (V522) Prevent possible null-pointer dereference in RemoveRPathELF
77b874baa8 pvs-studio: (V1086) Fix buffer writes
a77b7aa836 pvs-studio: (V557) Harden array boundary checks
7217af55da pvs-studio: (V555) Clarify size_type comparison

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12077
2026-06-18 11:16:07 -04:00
Martin Duffy 77b874baa8 pvs-studio: (V1086) Fix buffer writes
Replace space-filling memset calls with bounded character initialization that
preserves null termination for the curses help text buffers.
2026-06-17 10:13:03 -04:00
Daniel Tierney b533f229b8 cmSbom: Generate SPDX data denoting project licenses 2026-06-15 14:40:26 -04:00
Daksh Mamodiya 7fdf315ba3 cmake: Populate help string from documentation table for -D entries
When a built-in cache variable is set via `-D <var>=<value>` with no
help text supplied, populate `HELPSTRING` from the built-in
documentation table (sourced from `Help/variable/*.rst` and the
per-language pattern manuals).  Project-defined and unknown variables
continue to receive the legacy "No help, variable specified on the
command line." sentinel.

The cache entry's type and value are left untouched: type stays
`UNINITIALIZED` for bare `-D` and an explicit `-D <var>:TYPE=<value>`
is honored as before.  The `cmCacheManager::LoadCache` path is not
modified, so reload of existing caches is a fixed point.

Fixes: #27830
2026-05-28 09:25:41 -04:00
Christopher Wellons d20a05725e debugger: test breakpoint matching with mismatched path case
The existing tests use "C:/CMakeLists.txt", which is only absolute on
Windows.  ToNormalizedPathOnDisk resolves relative paths against the
working directory, so give the tests a platform-appropriate absolute
path via kTestSourcePath.

Add three tests that set breakpoints using a different letter case
than the path passed to SourceFileLoaded or GetBreakpoints, covering
all three NormalizePath call sites.  The tests create a real file on
disk so that ToNormalizedPathOnDisk can resolve the canonical case,
and skip gracefully on platforms where ToNormalizedPathOnDisk does
not correct on-disk case (case-sensitive filesystems, or CYGWIN which
is treated as POSIX).
2026-04-15 14:39:13 -04:00
Brad King 577ad8b487 debugger: Improve formatting of test source 2026-04-15 10:01:53 -04:00
Christopher Wellons 194232e2bc debugger: handle read errors on POSIX pipe and test abrupt disconnect
The POSIX pipe read wrappers stored the return of ::read() into an
unsigned result, so a negative count (e.g. EBADF from a concurrent
close on another thread) became SIZE_MAX. ContentReader::buffer()
would then try to grow its deque by ~18 exabytes and crash with
either std::length_error (glibc) or a stack smash (libc++). Treat
any non-positive ::read() return as EOF/error, close the pipe, and
return 0 so the peer's SessionThread observes a clean empty payload.

cmDebuggerPipeClient is test-only infrastructure; production cmake
is always the pipe server. Production close() assumes sequential
access, which holds in normal use (the adapter destructor joins
SessionThread before closing the connection). The new abrupt-
disconnect test however needs to wake a sibling thread blocked in
read() on the same fd, which Linux ::close() does not do.

Add a ShutdownForTesting() method that calls shutdown(SHUT_RDWR)
without freeing the fd, so any concurrent blocking read wakes
with a clean zero-length return. On Windows, CloseHandle already
cancels pending overlapped I/O, so the helper just forwards to
close(). Use it from testProtocolWithPipesAbruptDisconnect in
place of close().
2026-04-09 13:20:45 -04:00
Christopher Wellons 3490eff6f5 debugger: fix infinite loop when debugger pipe is closed
When a DAP client closes the pipe (or crashes), getPayload() returns an
empty functor without triggering the onError handler, so SessionActive
is never set to false and the session thread spins in a tight loop at
100% CPU. Handle the empty-payload case with the same cleanup performed
by the onError and DisconnectRequest handlers.

testProtocolWithPipesAbruptDisconnect drives the DAP handshake and then
closes the client side of the pipe without sending a DisconnectRequest.
The test deliberately avoids ReportExitCode so that no concurrent write
triggers the dap::Session error handler and masks the busy-loop
condition; if the SessionThread spins on EOF, the adapter destructor
blocks in SessionThread.join() and the test fails on a 10-second
timeout.

Fixes: #27743
2026-04-09 10:56:14 -04:00
Matthew Woehlke b8b0bf1f27 cmListFile: Use cmMakefile to issue messages
Modify cmListFile[Parser] to use cmMakefile rather than cmMessenger as
the interface for issuing messages. This is necessary to provide a
context for diagnostic messages so that they can be controlled via the
diagnostic state (which is not owned by cmMessenger).

Note that we actually bypass the cmMakefile when issuing errors, as
these cannot be disabled (so the diagnostic context doesn't matter), and
we want the calling cmMakefile to still be able to issue its own errors,
which would be suppressed if the cmMakefile has already issued an error.
2026-03-20 14:20:23 -04:00
Marc Chevrier a5882e9abe cmext/algorithm: Fix return type of cm::keys and cm::values 2026-03-19 15:23:27 +01:00
vvs31415 b4c6db0f52 cmListFile: Use std::string in place of const char* 2026-03-09 17:16:35 -04:00
Marc Chevrier 63775fe60f FILE_SET: add the support of properties for file set inspection 2026-02-28 13:46:57 +01:00
Daniel Pfeifer cc4d222eb5 cmScriptGenerator: Add Quote utility 2026-02-26 14:12:34 +01:00
Marc Chevrier dee8799d16 FileSet management: Introduce dedicated classes for generation
To manage the generation step, introduce cmGeneratorFileSet and
cmGeneratorFileSets classes.
These reorganizations of the code are done in preparation of the
implementation of SOURCES file set type as well as user's file set types.

Issues: #27550, #27383
2026-02-19 17:35:56 +01:00
Marc Chevrier c4c84ae0f7 cmFileSet: Enhance type management
Type management is now dynamic to ensure future support of user's types.
2026-02-19 17:03:45 +01:00
Brad King fec097038a Merge topic 'sbom-spec-fixes'
78f8b83ddb cmSbom: Fix names to ensure SBOM SPDX-3 compliance

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11700
2026-02-19 09:57:42 -05:00
Taylor Sasser 78f8b83ddb cmSbom: Fix names to ensure SBOM SPDX-3 compliance 2026-02-18 15:01:43 -05:00
Brad King ea47c154e5 Make case-dependent operations locale-independent
Use ASCII-only ctype operations provided by KWSys String.
These match the "C" locale in which `cmake` has long run.
2026-02-11 11:55:50 -05:00
Brad King 05ed2af7da Avoid signed char-to-int conversions in tolower/toupper calls
These functions document that the arguments must be representable
by `unsigned char`.  In particular, NetBSD is strict about this.

Fixes: #27574
2026-02-06 10:39:52 -05:00
Marc Chevrier 4113364c49 FILE_SET: properties management
Fixes: #27307
2026-01-27 18:15:26 +01:00
Marc Chevrier b86a77e8c8 cm::filesystem::path: ensure independence from the program locale.
Fixes: #27472
2026-01-15 19:44:14 +01:00
Brad King 824f2a7a20 Merge topic 'process-refactor'
d6111df5cb cmUVStream: Remove unused cmUVPipeIStream
c94d70c345 cmUVProcessChain: Open output streams automatically
ca0e9418f3 cmUVProcessChain: Simplify representation of merged streams
38ee29a66a cmUVProcessChain: Build stdout before stderr
ca0ba19d6d cmUVStream: Fix cmUVIStream constructor compilation with legacy XL compiler
5f54ad41e7 cmCTestScriptHandler: De-duplicate WaitForLine call
6f5bbf9ee7 cmSystemTools: Remove unused timeout argument from WaitForLine

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11532
2025-12-20 09:36:26 -05:00
Brad King d6111df5cb cmUVStream: Remove unused cmUVPipeIStream
All clients have been ported to cmUVIStream.
2025-12-19 07:52:30 -05:00
Brad King c94d70c345 cmUVProcessChain: Open output streams automatically
Avoid repeating the logic at every call site.
2025-12-19 07:52:29 -05:00
Brad King ca0e9418f3 cmUVProcessChain: Simplify representation of merged streams
Pretend the error stream is not connected so clients do not need
to have their own conditions to decide whether to read it.
2025-12-19 07:52:29 -05:00
Brad King 1b2b4f7e5f Tests: Clean up CMakeLib test include directories
Most include directories are available as `CMakeLib` usage requirements.
2025-12-18 13:49:14 -05:00
Matthew Woehlke 5564c2cd9a cmArgumentParser: Improve bad argument handling
Tweak ArgumentParser::ParseResult to store errors as a set, rather than
concatenating them. Add a new method that a) also optionally checks for
unknown arguments, and b) reports errors using the `SetError` method of
`cmExecutionStatus`, which allows callers to `return false`, which is
less surprising when an error occurs. This improves consistency at call
sites, reduces duplication by moving the common task of complaining
about unknown arguments to a reusable method, and also produces somewhat
more concise messages in the case that multiple errors occurred.

Note that, for some reason, the parser is sometimes generating duplicate
errors, hence the use of a set rather than a list.
2025-12-09 13:37:01 -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
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