file: Add filesystem-aware path comparison
cmake_path(COMPARE) is essentially useless because it doesn't compare paths case-insensitively or logically.
cmake_path(COMPARE) is virtually useless. Why not just do it manually considering that to properly compare paths on a filesystem or operating system that is case insensitive this fails anyway? Why does it compare lexicographically instead of logically checking paths? As a path tool, this is silly, redundant, and frankly programmer-hostile. The entire point of CMake is to take care of cross platform difficulties like this. cmake_path(COMPARE) fails to deliver on the hope of taking care off this mess.
cmake_path(COMPARE "C:\\" EQUAL "C:\\" testmebro)
message("testmebro: ${testmebro}")
cmake_path(COMPARE "C:\\" EQUAL "c:\\" testmebro)
message("testmebro: ${testmebro}")
Prints out "ON" (?) then "OFF". Side question: why ON/OFF instead of TRUE/FALSE??
The main difficult I forsee with this is that it is quite difficult to determine if an operating system and/or filesystem is being used case-insensitively. For example, NTFS is technically case-sensitive by default, but the Windows API usually passes an option for dealing with it that effectively makes it act case-insensitive. However, to support WSL, this is handy because NTFS is treated case-sensitively by Linux under WSL. It seems like a major pain in the butt to figure this out, but it's kind of what CMake is supposed to be for.
I have been working on a CMake sweetening library for a while now and have a get_filesystem_type
function that takes a path and returns the filesystem it is on, but this won't be enough to handle something like NTFS which can be either.
Still, roughly speaking, I think the code is going to go something like this: check the filesystem of the path and the operating system. If NTFS, also check, per directory, whether that directory is in case-sensitive or insensitive mode. fsutil.exe file queryCaseSensitiveInfo <path>
is the way to query this on Windows. We should also this wrapped up in a a FILE() call that returns whether a path is (or is in) a case-sensitive directory or not.
I'll update here if/when I get this function implemented.