Commit Graph

407 Commits

Author SHA1 Message Date
Ben Boeckel
93c3793829 cmSystemTools: adopt the GetActualCaseForPath method from KWSys
No other project uses it and it simplifies KWSys.
2026-07-29 14:15:27 -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
6e995093d9 Merge topic 'fix-build-tree-prefix-leak'
fd660330e0 find_*: Avoid searching prefix derived from CMake's own source tree

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12122
2026-06-04 09:51:29 -04:00
Daksh Mamodiya
fd660330e0 find_*: Avoid searching prefix derived from CMake's own source tree
When `cmake` is running from its own build tree, `CMAKE_ROOT` is in
the source tree and should not be used to derive a search prefix.

Fixes: #27853
2026-06-03 10:11:21 -04:00
Richard
dadbb71492 include/find_package: Warn on case-mismatched module names
Detect when the requested module name differs in case from the module
filename on disk.  Emit an author warning on Windows and Apple
platforms, where case-insensitive lookup can hide portability problems
on case-sensitive filesystems.

Fixes: #27811
2026-05-28 08:57:59 -04:00
Brad King
bfe5392276 Merge topic 'ctest-environment'
79c90b7afc cmSystemTools: Remove EnvDiff class
508a72fc1c cmCTestRunTest: Don't modify the current environment
61072fe317 cmcmd: Don't modify the current environment
31040ff609 cmEnvironment: Add class for environment modification
a5d0e0fb69 cmEnvironment: Introduce class for a set of environment variables
bf071f85fe cmSystemTools: Add env argument to RunSingleCommand
14edb7097f cmUVProcessChain: Add support for Environment

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11795
2026-03-12 14:00:59 -04:00
Daniel Pfeifer
79c90b7afc cmSystemTools: Remove EnvDiff class 2026-03-11 21:06:07 +01:00
Daniel Pfeifer
bf071f85fe cmSystemTools: Add env argument to RunSingleCommand 2026-03-11 20:46:54 +01: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
51e3b1b4b2 cmSystemTools: Simplify string case conversion methods
Take advantage of KWSys SystemTools' new move semantics.
2026-02-08 09:21:58 -05:00
John Franklin Rickard
35af170961 cmSystemTools: Take view instead of ref as parameter 2026-02-06 12:27:23 -05:00
John Franklin Rickard
c99ea2f78e cmSystemTools: Add string_view FileName and Extension Getter 2026-02-06 12:27:13 -05:00
Brad King
923902ceff cmSystemTools: Clarify "tar" archive argument names 2026-02-01 14:57:39 -05:00
Brad King
6f5bbf9ee7 cmSystemTools: Remove unused timeout argument from WaitForLine
The only call sites just retries on timeout anyway.
2025-12-19 07:52:29 -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
AJIOB
94ae247d44 cli tar: support different algorithms for zip & 7z
Fixes: #27443
2025-12-11 12:00:31 -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
cbf71b21b2 cli tar: support multithreading compression
Fixes: #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
Frank Winklmeier
fb7a904e90 cmcmd: report system errors on more filesystem operations
Print the system error message in case of failure when calling
`CopyFileAlways`, `CopyFileIfDifferent`, `CopyFileIfNewer`,
`CopyADirectory` and `MakeDirectory`.

Remove unnecessary `cmSystemTools` wrappers for `CopyFileIfNewer` and
`CopyADirectory`.

Fixes: #18276
2025-11-12 11:53:35 -05:00
Brad King
a2a626055b cmSystemTools: Return KWSys Status from RepeatedRemoveDirectory
This provides the OS-reported error on failure.
2025-10-31 08:42:59 +03:00
John Drouhard
fe0e2fcaff ScopedEnv: add a RAII helper to temporarily manipulate the environment 2025-09-08 16:22:58 -05:00
Benjamin Buch
8797912e4d cmake -E: Add copy_if_newer and copy_directory_if_newer
Fixes: #24923
2025-07-31 10:55:59 +02:00
Brad King
d7dbfa22a1 cmSystemTools: Drop unused MakefileColorEcho function 2025-05-19 08:19:20 -04:00
Brad King
cef4676d3a StdIo: Factor out helper to initialize stdin, stdout, and stderr
Move logic from commit c85524a94a (Ensure stdin, stdout, and stderr pipes
are always open, 2019-05-02, v3.15.0-rc1~171^2) and commit 96010cc968
(Ensure stdin, stdout, stderr FILE streams are open on Windows, 2024-01-24,
v3.29.0-rc1~65^2) to a dedicated source.  Expose it through an `Init` class
constructor to make it optionally available during static initialization.

Issue: #26924
2025-05-08 13:39:48 -04:00
Brad King
db0e2574cb cmSystemTools: Restore FindProgram look-up of on-disk case on Windows
KWSys's `FindProgram` no longer looks up the actual case on disk.  This
behavior change was inherited from the change to `CollapseFullPath`.
Extend commit 773b75e4ed (cmake: Explicitly look up on-disk case of
input paths on Windows, 2024-10-23, v4.0.0-rc1~589^2) to cover this by
wrapping `FindProgram` in a CMake-specific layer.

Issue: #20214
2025-04-07 19:57:07 -04:00
Brad King
5910bf0b40 cmSystemTools: Restore GetRealPathResolvingWindowsSubst
We need it to restore behavior on Windows.  Revert commit 16af27fd42
(cmSystemTools: Drop GetRealPathResolvingWindowsSubst, 2024-11-04,
v4.0.0-rc1~521^2), but with a cleaned up implementation.

Issue: #26750
Issue: #18033
2025-03-10 11:25:23 -04:00
Brad King
75913fe430 PathResolver: Document in comments the on-disk case lookup on macOS
This was added by commit 08040ced86 (cmake: Look up on-disk case of
input paths on macOS, 2024-11-20, v4.0.0-rc1~390^2).  Update relevant
comments.
2025-03-07 18:14:57 -05: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
Brad King
e388ed687a execute_process: Improve invocation of .cmd/.bat with spaces
Extend the fix from commit 74c9d40876 (execute_process: Fix invocation
of .cmd/.bat with spaces, 2025-01-31) to work without relying on
conversion to a "short path", which may not exist.  Instead, extending
the `cmd /c` wrapper to `cmd /c call` seems to support spaces directly.

Suggested-by: Alexandru Croitor <alexandru.croitor@qt.io>
Fixes: #26655
2025-02-10 19:44:19 -05:00
Brad King
817b3967f8 cmSystemTools: Teach MaybePrependCmdExe to return GetShortPathNameW failure 2025-02-03 09:09:29 -05:00
Brad King
98fed0f116 cmSystemTools: Adopt MaybePrependCmdExe 2025-01-31 11:52:09 -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
Tim Blechmann
339c2b886a cmSystemTools: Add RandomNumber method that avoid re-seeding from OS
When profiling Qt builds on macos, about 2.2% of a `cmake` invocation
was spent reading from `/dev/urandom`.  Use a (thread)local rng to
mitigate this cost, particularly in `cmGeneratedFileStreamBase::Open`.
2025-01-09 11:17:20 -05:00
Brad King
135e6feba9 Merge topic 'find-cps'
d00201afd6 Tests: Add tests for CPS find_package
65429611b9 find_package: Fix handling of relative paths in CPS
5236984a08 Help: Describe CPS support in find_package
34828650d6 find_package: Add experimental gate for CPS support
25cc83428e find_package: Actually import .cps files
91c31ada23 find_package: Actually find .cps files
b89e43b2bc find_package: Start implementing CPS search
3e9f96079d Add additional string case functions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10018
2024-12-17 10:12:24 -05:00
Matthew Woehlke
3e9f96079d Add additional string case functions
Add function to perform case-insensitive comparison of two string-view
instancess. Add functions to perform case conversion on string_view.
2024-12-13 08:58:23 -05:00
Russell Greene
01d2a64980 cmSystemTools: Add GetDirCase helper function
On Linux, one can set case insensitivity on a per-directory level.
2024-12-11 16:26:01 -07:00
Brad King
16af27fd42 cmSystemTools: Drop GetRealPathResolvingWindowsSubst
It was created by commit 83630d4918 (cmSystemTools: Revert GetRealPath
implementation on Windows, 2018-05-29, v3.11.3~3^2) to preserve support
on Windows for one call site.  Now that `GetRealPath` works again on
Windows, we can use that instead.

Issue: #18033
2024-11-04 12:03:56 -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
622596c6b2 cmSystemTools: Re-implement ToNormalizedPathOnDisk without translation map
Use `cm::PathResolver`'s `LogicalPath` variant to normalize paths while
preserving symlinks not followed by `..` components.  This avoids
needing the KWSys path translation map to preserve symlinks through
`realpath` operations.  It also works with symlinks on Windows.

Fixes: #16228
2024-11-03 08:26:43 -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
9fe09ebc53 cmSystemTools: Add GetEnvPathNormalized to get paths from environment 2024-10-22 13:24:40 -04:00
Brad King
2108f3507f cmSystemTools: Add SplitEnvPathNormalized to split paths from environment 2024-10-22 13:23:27 -04:00
Brad King
6d57403e14 cmSystemTools: Fix SplitEnvPath to avoid empty paths 2024-10-22 13:23:27 -04:00
Brad King
2503b43b6c cmSystemTools: Add ToNormalizedPathOnDisk helper
`CollapseFullPath` currently accesses the filesystem on Windows to
convert the path to the (upper/lower) case it has on disk.  Not all call
sites need this, so we'd eventually like to remove the behavior.  Add a
wrapper for call sites to express that they need to match the case of
on-disk paths.

Issue: #20214
2024-10-22 13:23:26 -04:00
Yuri Witte
d8a9aabd24 file(ARCHIVE_CREATE): add WORKING_DIRECTORY option
Fixes: #25260
Issue: #21653
2024-09-11 09:52:32 -04:00
Alexey Edelev
9ab270f47d cmSystemTools: Add GetComspec method to get cmd on Windows
The function attempts to read the path to cmd executable from the
COMSPEC environment variable. Falls back to cmd.exe if the respective
environment variable is not set or path doesn't exist.
2024-08-21 11:05:16 +02:00
Alex Turbov
dc38f81237 cmSystemTools: Revise MoveFileIfDifferent to return cmsys::Status
Help callers recover errors without relying on global state.
2024-07-18 10:29:47 -04:00
Martin Duffy
5b3fbd5f64 cmSystemTools: Add CMake config directory 2024-07-03 09:34:41 -04:00