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
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
KWSys's `CollapseFullPath` no longer looks up the actual case on disk.
Add the lookup explicitly where we need it:
* `ToNormalizedPathOnDisk`
* `file(REAL_PATH)`
* `get_filename_component(... ABSOLUTE)`
Fixes: #20214
If the connection fails in a way that might be a certificate error, and
verification was enabled by the new default, mention environment
variable `CMAKE_TLS_VERIFY` in the diagnostic to help users that were
relying on the old behavior turn off server certificate verification in
their environment.
Fixes: #23608
7486f468fb curl: Avoid using HTTP/2 with curl 8.7.x due to bug in error codes
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9728
If CMake is linked to a system-provided curl shared library, the version
at run-time may not match the `LIBCURL_VERSION` at build time. Look up
the run-time curl version to populate the User-Agent string.
This is particularly important since commit d3cbee99e3 (macOS: Prefer
building with system-provided curl, 2024-05-09, v3.30.0-rc1~130^2~1)
switched to building our official binaries on macOS against the system
provided curl shared library.
Fixes: #26209
f2596dfa0e macOS: Work around bug in system curl 8.{3,4,5} LibreSSL backend
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !9663
Since commit d3cbee99e3 (macOS: Prefer building with system-provided
curl, 2024-05-09, v3.30.0-rc1~130^2~1) CMake uses the macOS-provided
curl, which uses the LibreSSL backend by default. This exposes us to
curl issue 12525, created and fixed by the following upstream curl
commits:
* commit `bec0c5bbf` (openssl: switch to modern init for
LibreSSL 2.7.0+, 2023-08-07, `curl-8_3_0~201`)
* commit `9f2d2290d` (openssl: re-match LibreSSL deinit with init,
2023-12-15, `curl-8_6_0~219`)
Work around the bug by preferring the secure-transport backend by
default on the problematic versions of curl.
Projects may be generating a list of files or directories to pass as arguments
to file(TOUCH), file(TOUCH_NOCREATE), or file(MAKE_DIRECTORY). Those
lists might end up being empty, so rather than requiring at least one item,
allow an empty list.
Fixes: #24897
a820877d03 errors: avoid constructing a stream before getting the last error
5cf7018af6 cmFileCopier: remember error statuses and get their strings
0639a32d3a cmFileTimes: return status codes from APIs
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9023
Replace `FileExists || FileIsSymlink` with `PathExists`.
The latter does not resolve symlinks, so this is OK for use
with broken symlinks, files, and directories.
Refactoring in commit bff468c988 (cmFileCommand: Use cm::optional for
keyword argument presence, 2022-06-30, v3.25.0-rc1~512^2) accidentally
broke the check that the input argument is either `INPUT` or `CONTENT`.
The check is supposed to fail when arguments are passed in the wrong
order. For example:
file(GENERATE OUTPUT ...
TARGET <target>
CONTENT <content>)
Prior to this fix, the input method would be CONTENT, but because the
first parsed keyword is not `CONTENT`, `inputIsContent` would be false.
The first parsed keyword isn't INPUT either, so we would not continue
into the error condition. CMake would then try to handle this as an
input file, when there isn't one, resulting in uninitialized memory
usage and segfaults or corruption later on.
Fixes: #25169
Previously REAL_PATH would collapse paths before resolving any symlinks
so if `..` crossed a symlink the output from `REAL_PATH` would be wrong.
It looked like REAL_PATH did this by mistake since it was a side-effect
of ensuring we had an absolute path before resolving symlinks.
Previously, MAKE_DIRECTORY would print `problem creating directory: {}`,
which was very unhelpful for debugging. Extend the message with the
OS error string.
On Windows, a file may be inaccessible for a short time after it is
created. This occurs for various reasons, including indexing, antivirus
tools, and NTFS's asynchronous semantics. Add an `INPUT_MAY_BE_RECENT`
option to tell CMake that the input file may have been recently created
so that we can retry a few times to read it.
This allows the Zstd compression-level to be set between 0-19. I've
adjusted some of the tests, and error messages to indicates the selected
algorithm, and min/max of its compression-level.
Fixes: #24160
When `file(DOWNLOAD <url> EXPECTED_HASH <hash> LOG <logs>)` fails to
download the requested file, the hash check will also fail and make the
command exit without actually returning the curl logs as requested
by the `LOG` argument. Report the log before checking the hash.
Issue: #24093
8fc822e13a file: Avoid strange istringstream crash in cmake.org binaries on Alpine Linux
31f158e4c8 cmStringAlgorithms: Add functions to parse strings to long long integers
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7698
Somehow using `istringstream` and `operator >>` to parse an integer
crashes on Alpine Linux, at least when compiled with the settings we use
for the official `cmake.org` Linux binaries. Since commit fd0c285b12
(file: Fix types of the OFFSET and LIMIT arguments, 2022-01-04,
v3.23.0-rc1~133^2), this causes the `file(READ)` command to crash when
parsing its `LIMIT` or `OFFSET` argument. Parse the input string with
our dedicated helper to avoid the crash.
Fixes: #23872