Description | "cmake -E compare_files" is currently the equivalent of cmp(1), in that it checks whether or not two files are bit-for-bit identical. If you compare two text files that are the same except for one having Unix/LF line endings and the other having DOS/CRLF line endings, compare_files will indicate that they are different.
This behavior is not helpful when the files are unavoidably going to differ in EOL convention. In my case, I have a CMake framework to build a text-processing tool that is native to Unix, but is also usable in Windows. There is a test suite, in which the tool generates textual output, and the output is compared to a reference file. On Windows, the tool necessarily outputs CRLF text. But the test-reference files are necessarily LF, because they were produced on Unix, where the tool is maintained.
Currently, I am using CONFIGURE_FILE() as an improvised way of converting the tool-output file from CRLF to LF so that compare_files can work as intended, and the test suite gives meaningful results. However, this won't work if the file happens to contain "${VAR}" and "@VAR@" constructs, and while COPYONLY would be safer, it is not compatible with the necessary NEWLINE_STYLE directive.
What is really needed is an option to compare_files that tells it to compare the two files as text, disregarding any differences in the line-ending convention. |