1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-12 08:05:28 +08:00

913 Commits

Author SHA1 Message Date
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
4db9e1009d Solaris: Backport our mkdtemp code paths to SunOS 5.10 i386
`mkdtemp` is not available on this architecture until SunOS 5.11.
Look up the symbol at runtime, and if missing, fall back to an
approximate implementation.
2025-02-09 13:29:39 -05:00
Brad King
c1f6b04176 cmSystemTools: Teach MaybePrependCmdExe to always use backslashes 2025-02-03 09:13:18 -05:00
Brad King
817b3967f8 cmSystemTools: Teach MaybePrependCmdExe to return GetShortPathNameW failure 2025-02-03 09:09:29 -05:00
Brad King
611a3000f7 cmSystemTools: Make MaybePrependCmdExe case-insensitive 2025-02-03 09:05:47 -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
Kitware Robot
b2ba64add9 Revise C++ coding style using clang-format-18
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  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.

Fixes: #26123
2025-01-23 11:43:06 -05:00
Brad King
72e27a4856 Merge topic 'fix-typos-found-by-pre-commit-hooks'
d620d77d26 FindDoxygen: Rename `_Doxygen_dne_header` -> `_Doxygen_do_not_edit_header`
e7ff3cccea PushToAndroidDevice.cmake: Rename `cmake_parse_arguments` prefix
bc8621d999 Fix: A lot of typos in code found by `typos`
b33beb7af5 Help: Fix some typos found by `sphinx-lint`
78e45c2db6 Style: Replace TABs with spaces for indentation in some files
74e0173f66 Tests(NuGet): Fix the test to ignore empty and space-only lines

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10151
2025-01-14 09:44:34 -05:00
Brad King
80bac4de30 Merge topic 'cmake-self-symlinks'
6d9ab7964d cmake: Restore finding installed resources in their real path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10160
2025-01-13 11:19:56 -05:00
Alex Turbov
bc8621d999
Fix: A lot of typos in code found by typos
Yet another great code spellchecker: https://github.com/crate-ci/typos/

(Will be added later as a `pre-commit` hook)
2025-01-12 18:49:34 +04:00
Brad King
6d9ab7964d cmake: Restore finding installed resources in their real path
In commit 0994bc7929 (cmake: Preserve symlinks in references to itself
when possible, 2024-11-11) we stopped looking for resources using the
real path of the directory containing `cmake`.  Restore it as a fallback
to support layouts like `/{bin -> usr/bin}/cmake`.

Fixes: #26570
2025-01-09 16:23:54 -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
79e41d3cc6 Merge topic 'rpath-preserve-setuid-setgid'
0907a322f3 install: Restore SETUID/SETGID after RPATH change

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10053
2024-12-20 09:18:24 -05:00
Volodymyr Zolotopupov
0907a322f3 install: Restore SETUID/SETGID after RPATH change
Most Unix-like systems drops the SETUID/SETGID bits when a file changes,
so after changing the RPATH, it is necessary to restore
the original file mode.
2024-12-19 08:29:44 -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
YunQiang Su
08040ced86 cmake: Look up on-disk case of input paths on macOS
Follow up commit 1a6015e5fc (PathResolver: Add helper to compute
normalized paths, 2024-10-30) to cover on-disk case lookup on macOS.

Fixes: #26333
2024-12-01 07:12:51 -05:00
Brad King
0994bc7929 cmake: Preserve symlinks in references to itself when possible
CMake's tools search relative to their own locations to find their
resources.  Previously they always started at their own `realpath()`.
The intention was to support invocation through symbolic links to the
binaries where the resources can only be found under the real prefix:

    /logical/prefix/bin/cmake   -> /real/prefix/bin/cmake
                                   /real/prefix/share/cmake

The generated build system refers to CMake's own tools and resources
through the `/real/prefix`.  This is not desirable in the case that the
`/logical/prefix` is meant as the canonical location and uses symbolic
links for both tools and resources as an implementation detail:

    /logical/prefix/bin/cmake   -> /real/prefix/bin/cmake
    /logical/prefix/share/cmake -> /real/prefix/share/cmake

In this case, the generated build system should refer to CMake's own
tools and resources through the `/logical/prefix`.  This way the
`/real/prefix` can be changed, and the symbolic links updated,
without breaking already-generated build systems.

Fixes: #19849
Fixes: #21059
Inspired-by: Carlo Cabrera <github@carlo.cab>
Inspired-by: Rodger Combs <rodger.combs@gmail.com>
2024-11-11 11:53:59 -05:00
Brad King
0925abb09b cmSystemTools: Invert condition to make non-bootstrap logic easier to follow 2024-11-11 11:53:00 -05:00
Brad King
46ac308249 cmSystemTools: Factor out helpers from FindCMakeResources
Factor out helpers to:

- Find our own executable
- Find resources in the install tree or the build tree
2024-11-11 11:49:43 -05:00
Brad King
b91ec8c48f cmSystemTools: Clarify decision to look for resources from the build tree 2024-11-11 11:49:43 -05:00
Brad King
cbee4eed0f cmSystemTools: Re-order resource and tool finding logic
Consolidate `CMAKE_BOOTSTRAP` conditions.
2024-11-11 11:49:05 -05:00
Brad King
f6acf1f7b7 cmSystemTools: Reduce rightward drift in success path on UNIX 2024-11-11 10:27:34 -05:00
Brad King
962e4479d4 cmSystemTools: Clarify app bundle layout on macOS 2024-11-11 10:27:34 -05:00
Brad King
56632ddaa3 cmSystemTools: Remove redundant filesystem access on Windows
Since commit 823e1df54c (cmSystemTools: Implement GetRealPath on
Windows, 2024-11-04), GetRealPath now returns the actual case
on disk.  It also returns the original path on failure.
2024-11-11 10:27:34 -05:00
Brad King
f2b3907cd0 cmSystemTools: Move static data to anonymous namespace 2024-11-11 10:27:33 -05: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
b378781c5d cmSystemTools: Cache ToNormalizedPathOnDisk actual-case lookups
Prior to re-implementing `ToNormalizedPathOnDisk`, its use of KWSys's
`GetActualCaseForPathCached` cached file actual-case lookups to avoid
redundant filesystem access.  Add caching to the actual-case lookups we
do for `cm::PathResolver`.
2024-11-03 08:30:30 -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
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
Brad King
ee83165923 cmake: Explicitly normalize input paths as they exist on disk
`CollapseFullPath` has two use cases:

1.  Normalize input paths from command-line arguments and environment
    variables.  On Windows, load their on-disk capitalization.

2.  Simplify paths constructed internally.  These should already have
    the correct capitalization.

Audit all `CollapseFullPath` call sites and code paths leading to them.
Replace those calls that normalize input paths with calls to
`ToNormalizedPathOnDisk` to express that they need the on-disk case.

By making this distinction we will later be able to remove the on-disk
capitalization lookup `CollapseFullPath`, thus eliminating disk accesses
from internal path processing.

Issue: #20214
2024-10-22 13:26:19 -04: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
Daniel Pfeifer
58c5f77837 clang-tidy: fix readability-redundant-* warnings 2024-10-11 15:37:21 +02:00
Yuri Witte
d8a9aabd24 file(ARCHIVE_CREATE): add WORKING_DIRECTORY option
Fixes: #25260
Issue: #21653
2024-09-11 09:52:32 -04:00
Vitaly Stakhovsky
58da4aa47d Source: Avoid comparing pointers to nullptr 2024-08-27 10:56:38 -04:00
Brad King
3d61720112 Merge topic 'autogen-predefs-emscripten'
8d1803d463 AutoGen: Run batch scripts using cmd.exe on windows platforms explicitly
9ab270f47d cmSystemTools: Add GetComspec method to get cmd on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9733
2024-08-22 09:03:05 -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
fc36ac6b22
Refactor: Eliminate redundant operator<< calls 2024-08-14 19:56:54 +04:00
Alex Turbov
3855131c53 Refactor: Eliminate sequential calls to cmSystemTools::Stdout 2024-08-13 22:14:05 +04: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
Harmen Stoppels
02f3e5be6a file(RPATH_CHANGE ...): no-op for static binary
Setting `CMAKE_INSTALL_RPATH` on a project that contains statically
linked executables breaks the install step, since rpaths cannot be
changed.

This commit makes rpath adjustments not an error on static libraries.

Fixes #26078
2024-06-24 11:32:30 -04:00
Brad King
a66dfe22d7 Merge topic 'ctest-windows-std-handles'
e4d0169107 ctest: Fix spurious build failures with CTEST_USE_LAUNCHERS on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9598
2024-06-14 09:27:06 -04:00