Commit Graph

37716 Commits

Author SHA1 Message Date
Martin Duffy 6e637b1102 install(PACKAGE_INFO): Fix error when usage requirements contain certain genex
Since commit 13c7bb5b0c (cmGeneratorExpression: Update strip function to
collect parsed expressions, 2025-04-08, v4.1.0-rc1~361^2~1), the logic
to strip generator expressions would error if the stripped expressions
were being collected and an expression without a `:` was found inside an
expression with a `:`. This resulted in an error when exporting a target
that contained such a generator expression in its link libraries or
compile definitions.

Address the error by checking whether the latest `$<` proceeded the
latest `:`.
2025-10-17 11:34:43 -04:00
Brad King 58880d6773 Merge topic 'ninja-trailing-newline-comment' into release-4.1
12a225d56d Ninja: handle trailing newlines in variable stanzas

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11286
2025-10-07 08:58:51 -04:00
Ben Boeckel 12a225d56d Ninja: handle trailing newlines in variable stanzas
When a variable ends with a newline, the Ninja generator escapes it as
expected with `$\n`. However, when writing it out, whitespace is
trimmed. This leaves a trailing `$` instead which consumes the newline
and masks the following stanza. In a custom command, this hides the
`restat = 1` setting.

Detect this case and restore the newline as necessary.

See: #25983
2025-10-06 09:54:15 -04:00
Robert Maynard 87a661a916 find_package: Fix regression on <PackageName>_ROOT relative to CWD
In commit 9d44a77454 (find_*: Explicitly normalize found paths as they
exist on disk, 2024-10-17, v4.0.0-rc1~597^2~1), we removed path
normalization from the internal `cmSearchPath::AddPathInternal` helper.
Most call sites were updated to normalize input paths first, but search
paths derived from `<PackageName>_ROOT` CMake variables are no longer
normalized.  Instead we normalize the path to the file found after
searching.

When `find_package` "config" mode considers a candidate CMake package
configuration file, normalize its path before loading the adjacent
package version file so that the latter is loaded by absolute path.
Otherwise `cmMakefile::ReadDependentFile` interprets a relative path
with respect to the current source directory rather than the current
working directory.

Fixes: #27279
2025-10-02 15:30:13 -04:00
Brad King fc059e1978 Merge branch 'backport-pkg-root-var' into pkg-root-var 2025-10-02 15:28:03 -04:00
Brad King d029b828b2 find_package: Avoid repeating search for lower-case .cps file 2025-10-02 15:24:47 -04:00
Brad King 11f3f34077 CMake 4.1.2 2025-09-30 10:48:33 -04:00
Brad King e0bbe79cea CMP0189: Restore support for linking $<TARGET_PROPERTY:tgt,LINK_LIBRARIES>
In general we disallow references to transitive target properties, such
as `COMPILE_DEFINITIONS`, in `[INTERFACE_]LINK_LIBRARIES` properties,
because the latter establish the transitivity itself.  Prior to CMP0189,
the `[INTERFACE_]LINK_LIBRARIES` properties were not themselves transitive
in `$<TARGET_PROPERTY>` expressions, so existing projects have code like

    target_link_libraries(foo PRIVATE "$<TARGET_PROPERTY:tgt,LINK_LIBRARIES>")

Policy CMP0189's NEW behavior, introduced by commit b3da9c6d60 (GenEx:
Evaluate LINK_LIBRARIES target properties transitively, 2025-02-24,
v4.1.0-rc1~731^2), makes `$<TARGET_PROPERTY:tgt,LINK_LIBRARIES>`
transitive, causing the above to be rejected.  Since evaluation of a
target's link libraries can already encounter and handle other targets'
link libraries, allow it in this case.

Fixes: #27265
2025-09-29 10:51:01 -04:00
Brad King cb69f750bf cmGeneratorTarget: Factor out helper to detect LINK_LIBRARIES evaluation 2025-09-26 17:41:41 -04:00
Brad King 7ef733450c Merge topic 'bootstrap-devirtualization' into release-4.1
ea04e19daf bootstrap: Fix compilation with gcc 16 devirtualization

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11243
2025-09-25 09:00:39 -04:00
Brad King 21bc83344c Merge topic 'bootstrap-devirtualization' into release-4.0
ea04e19daf bootstrap: Fix compilation with gcc 16 devirtualization

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11243
2025-09-25 08:58:51 -04:00
Brad King ea04e19daf bootstrap: Fix compilation with gcc 16 devirtualization
Avoid including a header for a subclass whose implementation is not
compiled during bootstrap.

Fixes: #27256
2025-09-24 17:20:35 -04:00
Brad King 622044ce33 CMake 3.31.9 2025-09-24 13:24:34 -04:00
Brad King deb7b4b658 file(GENERATE): Record CMP0189 at each call site
Policy CMP0189, introduced by commit b3da9c6d60 (GenEx: Evaluate
LINK_LIBRARIES target properties transitively, 2025-02-24,
v4.1.0-rc1~731^2), takes effect at generation time, and so uses the
policy value as of the end of each directory.  However, some projects
may rely on `file(GENERATE)` with the policy's OLD behavior in order
to extract targets' *direct* dependencies from `LINK_LIBRARIES`.
Pending a first-class solution to that problem, make it easier for
projects to port to the policy's NEW behavior in general while
retaining the OLD behavior in an isolated context.

Fixes: #27220
2025-09-23 11:30:22 -04:00
Brad King 9b862e7013 cmGeneratorTarget: Pass genex evaluation context to IsTransitiveProperty 2025-09-23 10:57:22 -04:00
Brad King 77570a1ac1 GenEx: Consolidate target property evaluation context arguments 2025-09-21 20:20:03 -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
Brad King b40a53e931 GenEx: Factor out a dedicated evaluation Context structure
The context's local generator, configuration name, and language are
constant throughout evaluation.
2025-09-21 18:58:55 -04:00
Brad King e1035dc307 GenEx: Rename cmGeneratorExpressionContext to cm::GenEx::Evaluation
It has grown to hold information about the evaluation itself,
not just the context in which the evaluation occurs.
2025-09-21 18:58:55 -04:00
Brad King 905cfcfa12 cmGeneratorExpressionNode: Simplify EvaluateDependentExpression signature
The local generator is available in the evaluation context.
2025-09-21 18:58:55 -04:00
Brad King fe8e82090b cmGeneratorExpressionEvaluationFile: Constify some local generator usage 2025-09-21 18:58:55 -04:00
Brad King 8321178a23 cmFileSet: Constify local generator usage 2025-09-21 18:58:55 -04:00
Brad King edd51d646c CMake 4.0.4 2025-09-08 14:51:44 -04:00
Brad King a4dd4f3dad Merge topic 'ninja-custom-command-comment-syntax' into release-4.1
1bf48e34f4 Ninja: escape special characters in custom command comments

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11136
2025-09-03 10:20:15 -04:00
Brad King 08b9257473 Merge topic 'project-version-fix' into release-4.1
aa16b8eb9a project: Revert changes to VERSION handling

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11131
2025-09-03 10:17:12 -04:00
Brad King cd7cd67fd5 Merge topic 'curl-opt-proxytype' into release-4.1
c8143074cf cmCTestCurl: Avoid using undocumented type for CURLOPT_PROXYTYPE values

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11134
2025-09-03 10:13:30 -04:00
Brad King 2bc0c335ce Merge topic 'curl-opt-proxytype' into release-4.0
c8143074cf cmCTestCurl: Avoid using undocumented type for CURLOPT_PROXYTYPE values

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11134
2025-09-03 10:12:21 -04:00
Ben Boeckel 1bf48e34f4 Ninja: escape special characters in custom command comments
Considerations of Ninja's control sequences was not considered in
30fb5b1b22 (Ninja: add COMMENT to build statement descriptions,
2024-05-01) via !9484. Escape both newlines and dollar signs.

Fixes: #27181
2025-09-02 15:33:20 -04:00
Brad King c8143074cf cmCTestCurl: Avoid using undocumented type for CURLOPT_PROXYTYPE values
Since upstream curl commit `1a12663d06` (CURLOPT: bump `CURLPROXY_*`
enums to `long`, drop casts, 2025-07-28), the `CURLPROXY_*` constants
are integer literals instead of `enum curl_proxytype`.  It turns out
that `curl_easy_setopt` has always expected a `long` anyway, and that
`curl_proxytype` is not documented for public use.

Fixes: #27178
2025-09-02 11:41:10 -04:00
Brad King cc6dc6ba85 Merge topic 'cmPropertySentinel-definition' into release-4.1
319c427d2f cmPropertySentinel: update definition

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11129
2025-09-02 09:48:02 -04:00
Brad King ef8c5bbaf3 Merge topic 'var-check-before-usage' into release-4.1
d614e8fb3f cmLocalGenerator: check variables before usage

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11127
2025-09-02 09:42:40 -04:00
Vito Gamberini aa16b8eb9a project: Revert changes to VERSION handling
In c4d12d7d we changed how the project command handles various variables
and made the behavior consistent across all variables controlled by
the project command. The conditions under which project() modifies the
various VERSION variables are non-intuitive, but can be observed as
side-effects.

Because this behavior is observable, it requires a policy to be changed.
This commit reverts to the previous behavior until a policy is added
and adds a test for that behavior.

Fixes: #27142
2025-09-02 00:35:24 -04:00
Marc Chevrier 319c427d2f cmPropertySentinel: update definition
Reported by https://pvs-studio.com/en/blog/posts/cpp/1277/ (N8)

Issue: #27159
2025-09-01 09:39:30 +02:00
Marc Chevrier d614e8fb3f cmLocalGenerator: check variables before usage
Reported by https://pvs-studio.com/en/blog/posts/cpp/1277/ (N2)

Issue: 27159
2025-08-29 18:47:28 +02:00
Brad King ba8c4a15f1 CMake 4.1.1 2025-08-27 12:33:28 -04:00
Brad King e0cd3b7e7d Merge topic 'cmList-swap-fix' into release-4.1
071e8678de cmList: fix swap function definition

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex <leha-bot@yandex.ru>
Merge-request: !11101
2025-08-27 10:53:22 -04:00
Brad King cf9cdde33d Merge topic 'vs7-generator-utility-target-typo' into release-4.1
93a83bcc00 cmGlobalVisualStudio7Generator: fix initialization typo

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11100
2025-08-27 10:48:13 -04:00
Brad King 18b3dd1e91 Merge topic 'ninja-many-subdirs' into release-4.1
6de40e7a4d Ninja: Fix regression with `.bat` wrapper around `ninja`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Acked-by: Josef Angstenberger <code@jtxa.de>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !11111
2025-08-27 10:40:10 -04:00
Brad King 6de40e7a4d Ninja: Fix regression with .bat wrapper around ninja
Revise the change from commit 5a36d0c9e7 (Ninja: Fix regression with a
large number of subdirectories, 2025-03-04, v4.0.0-rc3~2^2) to use a
command-line length limit small enough for `.bat` files.

Fixes: #27153
2025-08-25 11:31:23 -04:00
Marc Chevrier 071e8678de cmList: fix swap function definition
swap function should be in the same namespace as the cmList class.

Reported by https://pvs-studio.com/en/blog/posts/cpp/1277/ (N1)

Issue: #27159
2025-08-21 17:19:52 +02:00
Ben Boeckel 93a83bcc00 cmGlobalVisualStudio7Generator: fix initialization typo
Typo introduced in b82a74d918 (generators: use GetSupportDirectory() in
more places, 2025-05-21) via !10812. Pointed out in a PVS-Studio blog
post.

See: https://pvs-studio.com/en/blog/posts/cpp/1277/ (N3)
2025-08-20 22:45:13 -04:00
Brad King 0ef525208c Merge topic 'ctest-T-test-timeout' into release-4.1
9dc3edbba8 ctest: Restore default test timeout for command-line `-T Test` step
8745e6308e ctest: Restore default of no time limit for command-line `-T Test` step

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11094
2025-08-20 10:01:00 -04:00
Brad King 9dc3edbba8 ctest: Restore default test timeout for command-line -T Test step
In commit 774fcbe49c (CTest: Base command line mode on top of scripting
commands, 2024-10-05, v4.0.0-rc1~653^2) the implementation of this step
was converted to use `ctest_test` internally.  That command has its own
default test timeout of 600s if the ctest "TimeOut" configuration value
is not set.  If "TimeOut" is not set then default it to our previous
command-line mode default test timeout.

Fixes: #27139
2025-08-18 14:30:56 -04:00
Brad King 8745e6308e ctest: Restore default of no time limit for command-line -T Test step
Refactoring in commit 83845184db (cmCTest: Move timing functions from
cmCTestScriptHandler to cmCTest, 2024-10-23, v4.0.0-rc1~576^2) enabled a
time limit even if the undocumented `CTEST_TIME_LIMIT` script variable
is not set.
2025-08-18 14:10:15 -04:00
Brad King 4445478ef7 Merge topic 'pkgc-import-system-fix' into release-4.1
d5f6cf5ba8 PkgC: Only remove system paths which are exact matches
93f77d8183 PkgC: Allow system paths during IMPORT, POPULATE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11078
2025-08-14 09:22:47 -04:00
Brad King 8fbddbc777 Merge topic 'genex-strip-nested' into release-4.1
8227028e49 string(GENEX_STRIP): Fix regression on nested generator expressions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11077
2025-08-14 09:20:08 -04:00
Martin Duffy 8227028e49 string(GENEX_STRIP): Fix regression on nested generator expressions
Since commit 13c7bb5b0c (cmGeneratorExpression: Update strip function to
collect parsed expressions, 2025-04-08), the logic to strip generator
expressions from a string made incorrect assumptions about the contents of
generator expressions, leading certain cases to be stripped incorrectly.

Clean up the logic and fix broken behavior, and add test coverage with
`string(GENEX_STRIP)`.

Fixes: #27133
2025-08-13 15:52:16 -04:00
Brad King 914803bf31 Makefile: Fix regression that prints unnecessary VT100 escape sequences
Since commit 509c424472 (StdIo: Replace uses of KWSys Terminal with
StdIo::Print, 2025-05-08, v4.1.0-rc1~151^2~2) we print unnecessary VT100
escape sequences to establish normal text even when not intending to
print color.  In combination with `CLICOLOR_FORCE=1`, this breaks
detection of implicit link information from compiler driver output.

Fixes: #27137
2025-08-13 15:30:25 -04:00
Brad King a0a9e48f85 StdIo: Fix Terminal abstraction to avoid unnecessary VT100 escape sequences
Fix commit 329d755dbd (StdIo: Add a Terminal abstraction to print color
text, 2025-05-06, v4.1.0-rc1~151^2~3) to avoid printing a VT100 escape
sequence for normal text if we did not print any sequence initially.
We already use this approach for Windows Console text attributes.

Issue: #26924
2025-08-13 15:30:24 -04:00