1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 19:08:07 +08:00
Commit Graph

538 Commits

Author SHA1 Message Date
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
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
Brad King
5aed3ee49d cmSystemTools: Add GetLogicalWorkingDirectory
Track the current working directory with symbolic links preserved.
2024-11-03 08:26:36 -05:00
Brad King
773b75e4ed cmake: Explicitly look up on-disk case of input paths on Windows
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
2024-10-24 16:09:38 -04:00
Daniel Pfeifer
281e9039cb cmWorkingDirectory: Unify error messages 2024-10-18 15:04:07 -04:00
Brad King
5e1a59dc2b file(DOWNLOAD/UPLOAD): Require minimum TLS 1.2 by default
Fixes: #25701
2024-09-26 10:10:20 -04:00
Brad King
8e92ee34f6 file(DOWNLOAD/UPLOAD): Verify TLS server certificate by default
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
2024-09-24 08:37:23 -04:00
Brad King
03d37ae3ff cmFileCommand: Clarify names and logic using optional<bool> 2024-09-24 08:36:30 -04:00
Brad King
844417294b Merge topic 'file-REAL_PATH-warn-non-existing'
00c1161b01 file(REAL_PATH): Warn on non-existing paths

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9806
2024-09-13 09:25:44 -04:00
Alex Overchenko
00c1161b01 file(REAL_PATH): Warn on non-existing paths
The command is documented to work only for cases that the referenced
path exists.

Fixes: #26260
2024-09-12 08:20:29 -04:00
Yuri Witte
d8a9aabd24 file(ARCHIVE_CREATE): add WORKING_DIRECTORY option
Fixes: #25260
Issue: #21653
2024-09-11 09:52:32 -04:00
Brad King
d060b05217 Merge topic 'macos-curl-user-agent'
1a74f95656 file(DOWNLOAD): Fix User-Agent to use run-time curl version

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9726
2024-08-15 09:37:00 -04:00
Brad King
3265458a79 Merge topic 'macos-curl-user-agent' into release-3.30
1a74f95656 file(DOWNLOAD): Fix User-Agent to use run-time curl version

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9726
2024-08-15 09:36:58 -04:00
Brad King
0460e71e1f Merge topic 'curl-http2'
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
2024-08-15 09:35:37 -04:00
Brad King
7486f468fb curl: Avoid using HTTP/2 with curl 8.7.x due to bug in error codes
curl 8.7.x has a bug in HTTP/2 error codes introduced by
commit `0dc036225` (HTTP/2: write response directly, 2024-01-31,
`curl-8_7_0~230`) and fixed by commit `5c59f9142` (http2 + ngtcp2:
pass CURLcode errors from callbacks, 2024-04-18, `curl-8_8_0~181`).

Fixes: #26200
2024-08-13 15:07:53 -04:00
Brad King
1a74f95656 file(DOWNLOAD): Fix User-Agent to use run-time curl version
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
2024-08-13 14:14:10 -04:00
Brad King
24f3862628 Merge topic 'macos-curl-backend'
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
2024-07-18 08:56:32 -04:00
Brad King
f2596dfa0e macOS: Work around bug in system curl 8.{3,4,5} LibreSSL backend
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.
2024-07-17 09:13:26 -04:00
Asit Dhal
95323c90a1 file(MAKE_DIRECTORY): Add optional RESULT keyword to capture failure.
Fixes: #26041
2024-06-24 02:20:43 +02:00
René Bertin
598bc70474 file: Add undocumented READ_MACHO subcommand on macOS
Provide a way to parse the architectures of a Mach-O binary.

Issue: #25952
2024-06-04 08:37:47 -04:00
Craig Scott
7c516f7e28 file(): TOUCH, TOUCH_NOCREATE and MAKE_DIRECTORY accept empty lists
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
2024-05-31 22:55:20 +10:00
Brad King
46faaf9667 file(DOWNLOAD|UPLOAD): Add CMAKE_TLS_VERIFY environment variable
Issue: #23608
2024-03-30 09:22:04 -04:00
Brad King
93886f5c7d file(DOWNLOAD|UPLOAD): Avoid unnecessary CMAKE_TLS_VERIFY variable lookup
If the `TLS_VERIFY` option is given explicitly, we do not need to check
the variable.
2024-03-30 09:21:45 -04:00
Arctic Lampyrid
f578515d02 cmGlobCacheEntry: Add helper to carry CONFIGURE_DEPENDS glob cache arguments 2024-03-20 02:30:53 +08:00
Brad King
434fe8a34b file(DOWNLOAD|UPLOAD): Add CMAKE_TLS_VERSION environment variable
Issue: #25701
2024-02-28 08:40:27 -05:00
Brad King
fb9a6cf909 file(DOWNLOAD|UPLOAD): Add CMAKE_TLS_VERSION variable
Issue: #25701
2024-02-28 08:40:27 -05:00
Brad King
8e6776b9f3 file(DOWNLOAD|UPLOAD): Add TLS_VERSION option for https connections
Add an option to specify the minimum allowed TLS version for https
connections.

Issue: #25701
2024-02-28 08:40:14 -05:00
Cristian Le
fa00928bcd file: STRINGS + REGEX store match results
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2024-01-09 16:36:55 -05:00
Brad King
d101cb07ec Merge topic 'cmFileCopier-error-loss'
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
2023-12-05 09:23:49 -05:00
Ben Boeckel
a820877d03 errors: avoid constructing a stream before getting the last error
Constructing a stream may involve operations that change the global
error state. Avoid the streams by using `cmStrCat` instead.
2023-12-01 22:58:05 -05:00
Ben Boeckel
f02c3c6181 cmFileCommand: combine string literals 2023-10-19 23:00:16 -04:00
scivision
f5ff17fcf2 Source: Remove redundant FileIsSymlink checks
Replace `FileExists || FileIsSymlink` with `PathExists`.
The latter does not resolve symlinks, so this is OK for use
with broken symlinks, files, and directories.
2023-09-18 16:35:10 -04:00
Robert Maynard
c85fd9a705 file: Clarify CMake only drops RPATHS's it added 2023-08-15 14:59:14 -04:00
Brad King
c05d06c6ed Merge topic 'file-GENERATE-arg-parsing'
88f90a72f1 file(GENERATE): Restore INPUT|CONTENT parse checking

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8694
2023-08-08 10:06:39 -04:00
Evan Wilde
88f90a72f1 file(GENERATE): Restore INPUT|CONTENT parse checking
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
2023-08-07 19:17:29 -04:00