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

7 Commits

Author SHA1 Message Date
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
Michael Pratt
2216843fd5 cm_cxx_filesystem: Improve detection of std::filesystem support on GCC
The check added by commit 40af103402 (cmCMakePath: do not use
std::filesystem::path with RH gcc-toolset-10, 2023-12-02, v3.28.0~5^2)
fails unnecessarily in some cases due to not inheriting
`std::string_view` publicly.

Inheritance into a class is private by default, and this std class has
public members that would be access restricted when used to create
public objects in the current scope.

On some versions of GCC, depending on standards options, this causes
either template instantiation errors, or "inaccessible base" or "not
declared" errors.

Fix by setting the inheritance to public.  This does not affect the
intention of the previous fix because the check still fails when using
gcc-toolset-10's standard library with clang.

Issue: #25458, #25453
2024-08-15 11:31:01 -04:00
Michael Hirsch
ad4481fa00 Source: Enhance check for C++17 filesystem support
* Add `lexically_normal` test for all platforms.

* On Windows, MinGW does not currently handle `lexically_normal()`
  correctly on UNC path, but MSVC and IntelLLVM do--add a comment
  on this to avoid future confusion.

* Add test with `\\?\` notation and `weakly_canonical` that also triggers
  the MinGW bug, but is fine with MSVC and oneAPI, for a more robust and
  comprehensive test.
2023-12-05 11:30:08 -05:00
Marc Chevrier
40af103402 cmCMakePath: do not use std::filesystem::path with RH gcc-toolset-10
Fixes: #25458, #25453
2023-12-04 17:39:06 +01:00
Brad King
ee9805ccd1 cm/filesystem: Fix crash with pre-C++11 std::string GNU ABI in C++17
The `remove_filename` and `replace_extension` methods compute an offset
between the whole path in a `std::string` and a part of a path in a
`std::string_view`.  This is done by subtracting their `.data()`
pointers.  However, C++17 adds a non-const `.data()` through which
modification of the string is allowed.  This means the copy-on-write
implementation used by the pre-C++11 std::string GNU ABI must reallocate
if the string has been copied.  Our subtraction then computes an offset
between two different allocations, which is undefined behavior.

The workaround in commit b3ca4f9ad1 (cm/filesystem: Work around crash
when compiled for CYGWIN/MSYS runtime, 2021-04-22, v3.21.0-rc1~271^2~2)
avoided the problem by calling the non-const `.data()` to reallocate
before constructing the `string_view`.  Instead, explicitly call the
const `.data()` method on the string, which does not reallocate.

Fixes: #22090, #23328
2022-10-20 18:31:50 -04:00
Marc Chevrier
eb583b0a66 cmake_path command: path management
Fixes: #19568, #20922
2020-09-06 10:52:25 +02:00
Marc Chevrier
d654bf3449 STL Support: Add cm::filesystem::path in <cm/filesystem> 2020-07-09 17:02:42 +02:00