Files
cmake/Source
Mickaël Germain 860583ceac if: Add PATH_IS_PREFIX operator
Testing whether one path is a prefix of another is possible today with
cmake_path(IS_PREFIX), but the idiom needs a separate statement plus a
scratch variable and takes the prefix as a variable name, so projects
reach for if(path MATCHES "^${prefix}") instead.  That is wrong whenever
the prefix contains a regex metacharacter, and it accepts siblings,
because '^/a/b' matches '/a/bc'.

Add a binary operator where the left operand is the candidate prefix and
the right is the path, matching the operand order of cmake_path(IS_PREFIX)
and $<PATH:IS_PREFIX> so that the same operation reads the same way on all
three surfaces.  Neither operand is normalized, matching the default of
cmake_path(IS_PREFIX) and the existing PATH_EQUAL operator, so '.' and
'..' are compared as ordinary components.  The test is non-strict, purely
lexical, and applies no relative-to-absolute reconciliation.

Add policy CMP0222 for compatibility, modeled on CMP0139.  The keyword
is consumed as an operator only when it appears in the second argument
slot, so a variable named PATH_IS_PREFIX keeps working in unary and
left-operand position.  What the policy covers is such a variable
appearing after another token, as in if(NOT PATH_IS_PREFIX AND other),
which becomes a configure error under NEW.

Since the operator is an if() spelling of cmake_path(IS_PREFIX) and shares
its implementation, test it by asserting the two agree over a corpus of
inputs rather than by restating expected values.  Those are pinned by the
cmake_path(IS_PREFIX) test, so the operator's tests stay limited to what
has no command equivalent, and no platform branching is needed because
parity holds whatever the host path model answers.

Fixes: #28040
2026-09-10 07:09:47 -04:00
..
2026-08-31 11:50:18 -04:00
2026-08-31 11:50:18 -04:00
2026-09-06 00:05:46 -04:00
2026-01-29 10:16:59 -05:00
2025-08-01 09:56:00 -04:00
2025-11-12 14:54:35 -05:00
2025-10-07 09:29:18 -04:00
2026-04-16 15:10:35 -04:00
2025-08-26 14:29:01 -07:00
2026-04-16 15:10:35 -04:00
2026-09-10 07:09:47 -04:00
2026-01-27 18:15:26 +01:00
2026-07-30 11:52:27 -04:00
2026-07-29 15:04:59 -04:00
2026-07-27 09:56:23 -04:00
2026-04-16 15:10:35 -04:00
2026-07-23 10:28:41 -04:00
2025-11-12 14:54:35 -05:00
2025-11-12 14:54:35 -05:00
2026-02-03 09:34:23 +03:00
…