cm::filesystem: Restore detection of std::filesystem support on Windows

Since commit b86a77e8c8 (cm::filesystem::path: ensure independence from
the program locale., 2026-01-05, v4.3.0-rc1~185^2) detection always
fails due on Windows to using `fs` instead of `std::filesystem`.

Also remove the `weakly_canonical` check I added in commit ad4481fa00
(Source: Enhance check for C++17 filesystem support, 2023-12-02,
v3.29.0-rc1~296^2).  It was a bad idea since it accesses the filesystem,
and so in general this can give false negative say in the case of
`CMAKE_BINARY_DIR` being on a symlinked drive.

Fixes: #28221
This commit is contained in:
scivision authored and Brad King committed 2026-10-29 11:09:05 -04:00
1 parent 1b053f63d2
commit 57c68e39ea
1 file changed
+2 -8
+2 -8
View File
@@ -26,20 +26,14 @@ int main()
return 1;
}
std::filesystem::path b1("C:\\path\\y\\..\\");
if (std::filesystem::weakly_canonical("\\\\?\\C:\\path\\x\\..") !=
b1.lexically_normal()) {
return 1;
}
// LWG 3070 not implemented on some old Visual Studio compilers (2017, for
// example)
// example), or on MinGW Clang.
if (!std::filesystem::path("/a:/b:").lexically_relative("/a:/c:").empty()) {
return 1;
}
// LWG 3096 not implemented on some old Visual Studio compilers (2017, for
// example)
if (fs::path("/a").lexically_relative("/a/.") != ".") {
if (std::filesystem::path("/a").lexically_relative("/a/.") != ".") {
return 1;
}
#endif