SameFile() slows down install actions on Windows
SameFile() is called as part of the up-to-date checks to determine if actually copying the file is necessary. The purpose of this seems to be an optimization, to avoid unnecessary file copies.
However, on Windows, the
SameFile() function is actually quite expensive, as it has to open both files with calls to
Additionally, it is my understanding that the file will in practice always return false, as CMake would have to create a hard link during the install action for it to return true, and at least on Windows, it never does this.
Therefore, I would suggest that
cmFileCopier::Install should only call
SameFile on non-Windows platforms, where encountering hard links in the first place is actually feasible, and where checking whether the files are the same is much cheaper (just a
stat() call, rather than having to open the files).
In my testing, I'm seeing a speedup for installs of around 30% just from removing this one call to