Adding a BOM to NMake artefacts to properly support UTF-8


I am reaching out to suggest that, when the ‘NMake Makefiles’ generator is used, response files should be encoded using UTF-8 with BOM.

Without this enhancement, the following build fails using CMake (3.18.5):

  1. create the CMakeLists.txt (in UTF-8):

cmake_minimum_required(VERSION 3.12)


The character in the main’s filename is the euro symbol.

add_executable(component main€.c)

  1. build:

cmake.exe “…” -G"NMake Makefiles"

cmake.exe --build .

You should see the following error:

[100%] Linking C executable component.exe

LINK Pass 1: command “C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1424~1.283\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\component.dir\objects1.rsp /out:component.exe /implib:component.lib /pdb:X:\Documents\cmake_example\utf-8-cmake-3.18.5\buildDir\component.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\component.dir/intermediate.manifest CMakeFiles\component.dir/manifest.res” failed (exit code 1104) with the following output:

LINK : fatal error LNK1104: cannot open file ‘CMakeFiles\component.dir\mainÔé¼.c.obj’

The UTF-8 encoded response file CMakeFiles\component.dir\objects1.rsp contains:


However, link.exe fails to process it because of the non-ascii character.

Adding a BOM (byte order mark) to the file fixes this type of issues.



This sounds reasonable to me. Could you please file an issue about this? Thanks.

Cc: @marc.chevrier @brad.king