diff options
author | Michael Hirsch <scivision@users.noreply.github.com> | 2023-12-03 01:24:17 (GMT) |
---|---|---|
committer | scivision <scivision@users.noreply.github.com> | 2023-12-05 16:30:08 (GMT) |
commit | ad4481fa00369f8ce043d326daf80bb349b0c99a (patch) | |
tree | b248d72649d5e664359d9d9d71da59dee3f6750e /Source/Checks | |
parent | 57b94595a3a0056aef1446ce1827dd945261d362 (diff) | |
download | CMake-ad4481fa00369f8ce043d326daf80bb349b0c99a.zip CMake-ad4481fa00369f8ce043d326daf80bb349b0c99a.tar.gz CMake-ad4481fa00369f8ce043d326daf80bb349b0c99a.tar.bz2 |
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.
Diffstat (limited to 'Source/Checks')
-rw-r--r-- | Source/Checks/cm_cxx_filesystem.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Source/Checks/cm_cxx_filesystem.cxx b/Source/Checks/cm_cxx_filesystem.cxx index c8df589..bdc7c6d 100644 --- a/Source/Checks/cm_cxx_filesystem.cxx +++ b/Source/Checks/cm_cxx_filesystem.cxx @@ -9,12 +9,13 @@ int main() std::filesystem::path p0(L"/a/b/c"); std::filesystem::path p1("/a/b/c"); - std::filesystem::path p2("/a/b/c"); - if (p1 != p2) { + std::filesystem::path p2("/a/b//c"); + if (p1 != p2.lexically_normal()) { return 1; } #if defined(_WIN32) + // "//host/" is not preserved in some environments like GNU under MinGW. std::filesystem::path p3("//host/a/b/../c"); if (p3.lexically_normal().generic_string() != "//host/a/c") { return 1; @@ -24,6 +25,12 @@ int main() if (p4.lexically_normal().generic_string() != "c:/a/") { return 1; } + + std::filesystem::path b1("C:\\path\\y\\..\\"); + if (std::filesystem::weakly_canonical("\\\\?\\C:\\path\\x\\..") != + b1.lexically_normal()) { + return 1; + } #endif // If std::string is copy-on-write, the std::filesystem::path |