[CMake] CMake can't handle Unicode files with BOM

kent williams nkwmailinglists at gmail.com
Tue Oct 19 13:11:28 EDT 2010


OK if anyone is tallying how many hours have been wasted on Unicode
files with BOM, add at least one for me.

This is a logged bug for CMake: http://public.kitware.com/Bug/view.php?id=11137

I assume that 2.8.4 or whatever will find a way to deal with this.
But my quick summary is this: A Unicode file with BOM causes CMake to
complain about the syntax of a CMake file, and many modern text
editors throw away the 3 byte BOM header -- BOM stands for 'Byte Order
Manifest', presumably telling you the byte order for the file. Which,
in the case of UTF-8 is silly because characters are only one byte
wide.

If you run into this, the solution is to strip the 3 characters from
the start of the file.  This is rather difficult unless you have an
editor that will display and allow you to delete them.  Here's a perl
script that will do it for you:

#!/usr/bin/perl
@file=<>;
$file[0] =~ s/^\xEF\xBB\xBF//;
print(@file);

Can CMake handle wide character CMakeLists.txt files?  Now that would
blow MY mind -- CMakeLists.txt in Arabic or Chinese.


More information about the CMake mailing list