571 Commits
Author SHA1 Message Date
AJIOB 1d2f0120be Source: Reduce string allocations, part 3 2026-09-22 11:37:41 +03:00
Ben Boeckel f188f74bbd KWSys: update for CopyWhen::{Always => Unconditional} rename
KWSys renamed `Always` to `Unconditional` because the former
conflicts with a X11 macro.
2026-08-08 10:25:19 -04:00
Daksh Mamodiya 9800bd2098 file(ARCHIVE_CREATE): Add PATTERNS_EXCLUDE option
Exclude files and directories matching the given patterns while creating
an archive, using libarchive's matcher for parity with file(ARCHIVE_EXTRACT).

Fixes: #27877.
2026-06-16 15:33:06 +02:00
Daksh Mamodiya 531f3b568c file(ARCHIVE_EXTRACT): Add PATTERNS_EXCLUDE option
Omit archive entries matching the given patterns when extracting or
listing. May be combined with PATTERNS; on overlap the exclusion
takes precedence.

Fixes: #27837
2026-06-11 02:04:36 +02:00
Brad King e65ed3996a Merge topic 'file-download-no-ssl-fix'
18d5daa7f3 file(DOWNLOAD/UPLOAD): Restore support for curl built without a TLS backend

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12104
2026-05-28 09:38:42 -04:00
Daksh Mamodiya 18d5daa7f3 file(DOWNLOAD/UPLOAD): Restore support for curl built without a TLS backend
Since commit 38390245a2 (ctest: Require minimum TLS 1.2 by default,
2024-09-23, v3.31.0-rc1~47^2), our TLS-1.2 default fails with a curl
built without any TLS backend, causing even `file://` and `http://`
URLs to fail.  Teach CMake to recognize both ways libcurl may report
that it was built without TLS support.

Fixes: #27849
2026-05-27 13:59:01 -04:00
Matthew Woehlke a7415d243a Diagnostics: Simplify issuing policy warnings
Add and use a couple helper functions for issuing policy warnings. This
improves consistency and allows some simplification of many call sites.
(One or two instances in particular are greatly simplified.)
2026-05-20 11:55:13 -04:00
Matthew Woehlke 028d3183ad Diagnostics: Add POLICY, EXPERIMENTAL
Add new diagnostic categories CMD_POLICY and CMD_EXPERIMENTAL, both as
children of CMD_AUTHOR. Use the former when issuing policy warnings. Use
the latter when issuing experimental feature warnings.
2026-05-15 09:57:23 -04:00
Brad King 9c3163a803 Merge topic 'read-symlink-result'
3f3ba04d81 file(READ_SYMLINK): Add RESULT option to capture errors
b5b72b0378 Tests/RunCMake/file: Enable READ_SYMLINK cases on Windows when possible

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11932
2026-04-20 09:36:44 -04:00
scivision 3f3ba04d81 file(READ_SYMLINK): Add RESULT option to capture errors
Closes: #27753
2026-04-17 10:51:28 -04:00
Matthew Woehlke 1309532390 Diagnostics: Use new methods
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
2026-04-16 15:10:35 -04:00
Brad King 25dd69d2f2 Merge topic 'file-link-copy-fix'
57ca3dc521 file(CREATE_LINK): Fix CMP0205 to not remove content behind directory symlink
a6470b4681 Help/file: Clarify behavior change with CMP0205
b894942d3e file(CREATE_LINK): Revise CMP0205 warning

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11925
2026-04-16 09:19:27 -04:00
Tyler Yankee 57ca3dc521 file(CREATE_LINK): Fix CMP0205 to not remove content behind directory symlink
When removing the destination directory link when it already exists
before making the new link, only the (destination) link should be
removed, not the (source) directory itself. When COPY_ON_ERROR is
specified and the destination is a directory, only then should CMake
remove it, since it could likely be placing a new directory there in
its place.

With this new behavior, adjust the conditions for the symlink test from
commit a73ddd2ddb (file(CREATE_LINK): Implement COPY_ON_ERROR for
directories, 2025-10-15, v4.3.0-rc1~599^2). The newly modified test
case should be run on systems that do and don't support directory
symlinks, with slightly different outcomes that are verified.

Fixes: #27747
2026-04-15 14:03:40 -04:00
Tyler Yankee b894942d3e file(CREATE_LINK): Revise CMP0205 warning
Ensure we only warn when COPY_ON_ERROR is specified. While we're at it,
tweak the spelling and apply consistent policy & logic ordering in
compound conditions.
2026-04-15 14:02:50 -04:00
AJIOB 97455c3d7e file: Add ARCHIVE_* options to specify pathname encoding
Issue: #26903
2026-03-24 14:07:21 -04:00
Alex Overchenko 21eb53e9eb tar: Add option to specify the encoding of archive pathnames
Use OEM by default for backward compatibility

Fixes: #26903
2026-03-11 08:44:44 +03:00
Brad King 6ec707312d Make character classification 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:54 -05:00
Brad King 55842d16ac cmFileCommand: Adopt file:// URL compatibility helper
Migrate the helper back from `cmCurl` because its only remaining
functionality is specific to the `file(DOWNLOAD)` and `file(UPLOAD)`
commands.
2026-02-09 10:04:59 -05:00
Brad King 6015ef807d cmake -E tar: Improve error message formatting
Do not print file paths with our prose line wrapping, which breaks
on spaces.
2026-01-16 08:53:28 -05:00
Alex Overchenko c42acbbecc Source: replace string addition to cmStrCat 2026-01-08 23:22:19 -05:00
AJIOB e347176424 file(ARCHIVE_CREATE): Add controls for zip and 7z compression method/level
Fixes: #27463
2025-12-17 14:38:30 -05:00
Leslie P. Polzer 8ada1bcf8c file(LOCK): Avoid truncating existing files
Previously the command opened the lock file using fopen with "w" mode,
which truncates the file to zero length. This is unsafe because:

1. If the lock file path is a symlink, the target file gets truncated
2. Race conditions between path resolution and file opening can be
   exploited to truncate arbitrary files

An attacker can exploit this by creating a symlink at a predictable
lock file location pointing to a critical file (e.g., source files,
configuration, or system files). When cmake runs file(LOCK), it
follows the symlink and destroys the target file's contents.

Fix by changing the file mode from "w" (write/truncate) to "a"
(append). This creates the file if it doesn't exist but preserves
existing content, preventing data destruction attacks.
2025-12-17 13:49:41 -05:00
AJIOB 94ae247d44 cli tar: support different algorithms for zip & 7z
Fixes: #27443
2025-12-11 12:00:31 -05:00
AJIOB fe173b68f0 Source: Use cmStrCat in place of string addition 2025-12-09 11:06:59 -05:00
Brad King 9149ac3f37 Merge topic 'fix-27420'
4fdfa0db1a file(ARCHIVE_CREATE): support multithreading compression
cbf71b21b2 cli tar: support multithreading compression

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11460
2025-12-05 09:04:58 -05:00
AJIOB 4fdfa0db1a file(ARCHIVE_CREATE): support multithreading compression
Relates: #27420
2025-12-03 02:45:30 -05:00
AJIOB 5b87a5d53e cli tar: implement LZMA support
Fixes: #27433
2025-12-02 10:44:49 +03:00
Brad King 3593aa59ef cmake: Replace working mode with role 2025-11-07 09:35:55 -05:00
Brad King 0aab75bf0e cmake: Clarify name of enum backing CMAKE_ROLE property 2025-11-07 09:35:53 -05:00
Hanna Rusakovich a73ddd2ddb file(CREATE_LINK): Implement COPY_ON_ERROR for directories
Add policy `CMP0205` for compatibility with projects not expecting this.

Fixes: #27294
2025-10-31 08:42:59 +03:00
Brad King f719a36bc0 file(CREATE_LINK): Refactor error handling for removal of destination
Avoid relying on global state.
2025-10-31 08:42:59 +03:00
Daniel Pfeifer b1fdab3cc1 source: Pass small and trivially copyable types by value 2025-08-01 09:56:00 -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
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
Brad King fefb49bc80 Merge topic 'macos-curl-backend' into release-3.31
1e1129c6fe macOS: Reliably apply workaround for system curl 8.{3,4,5} LibreSSL backend

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10724
2025-04-30 09:39:16 -04:00
Brad King 5d3f931956 Merge branch 'backport-macos-curl-backend' into macos-curl-backend 2025-04-29 11:50:17 -04:00
Gregor Jasny 1e1129c6fe macOS: Reliably apply workaround for system curl 8.{3,4,5} LibreSSL backend
In commit f2596dfa0e (macOS: Work around bug in system curl 8.{3,4,5}
LibreSSL backend, 2024-07-16, v3.30.1~2^2) we tried to prefer
`secure-transport` on problematic versions of curl.  However, the
`curl_global_sslset` setting must be applied before every
`curl_global_init` call, not just the first one.  Otherwise a
second (or subsequent) download won't apply the work-around.
2025-04-29 11:49:49 -04:00
Brad King b1c22bdc38 Source: Fix -Wformat warnings 2025-04-24 07:56:39 -04:00
Martin Duffy cc2cbfc61e file: Add more context to errors from file(DOWNLOAD) 2025-04-18 13:30:05 -04:00
Hanjiang Yu 9476245dcd file(DOWNLOAD): Handle write errors 2025-03-26 09:32:39 -04:00
Brad King 41d91387f6 Merge branch 'backport-3.31-file-MAKE_DIRECTORY-result-var' 2025-03-13 11:58:47 -04:00
Brad King 397ec37528 file(MAKE_DIRECTORY): Do not make directories for command keywords
In commit 95323c90a1 (file(MAKE_DIRECTORY): Add optional RESULT keyword
to capture failure., 2024-06-16, v3.31.0-rc1~414^2) we computed an
updated range of arguments, that name directories to be created, before
the `RESULT` keyword.  However, we forgot to use it in the loop.

Fixes: #26768
2025-03-13 11:57:53 -04:00
Brad King a039a1655d file(MAKE_DIRECTORY): Clarify formatting of unexpected arguments error 2025-03-13 11:57:27 -04:00
Brad King 90d9c79348 file(MAKE_DIRECTORY): Do not make directories for command keywords
In commit 95323c90a1 (file(MAKE_DIRECTORY): Add optional RESULT keyword
to capture failure., 2024-06-16, v3.31.0-rc1~414^2) we computed an
updated range of arguments, that name directories to be created, before
the `RESULT` keyword.  However, we forgot to use it in the loop.

Fixes: #26768
2025-03-13 11:57:25 -04: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
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
Brad King 77f8c374f3 CMP0009: Remove support for OLD behavior 2025-01-17 09:28:36 -05:00
Alex Turbov 8352a2d12f cmFileCommand.cxx: Optimize cmStrCat() calls 2024-11-19 17:57:57 +04:00
Brad King 659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Brad King 823e1df54c cmSystemTools: Implement GetRealPath on Windows
Use `cm::PathResolver`'s `RealPath` variant to normalize paths,
look up their on-disk case, and resolve symlinks, but without
resolving `subst` drives on Windows.

Fixes: #17206
2024-11-04 11:56:14 -05:00