AUTOMOC does not work on Windows if there are files with the same basename as the actual header
I encountered a problem on Windows in the current CMake master (as well as the 3.16 release candidate) that was not present in 3.15.4. The symptom was the error message "... includes the moc file ..., but the header ... could not be found in the following directories", while that file certainly existed in the first one of the search directories.
Upon investigation, I found out that this (or rather here) is responsible. Passing a path with a trailing dot to
CollapseFullPath and further down to
GetCasePathName leads to
FindFirstFileW getting called. If, in that directory, another file exists without the
.h suffix, but in a different case (there are possibly more constellations in which this breaks) that one might be returned by
FindFirstFileW instead, removing the trailing dot and causing the concatenated file name including the extension to be invalid.
(In my case, it was
qtbuttonpropertybrowser.h which should have been found and
QtButtonPropertyBrowser which was actually found)
It looks to me like moving the
CollapseFullPathTS inside the loop after the concatenation with the extension would fix it, but I do not know whether there are other instances of this problem.