CMake configure crashes and exits early in folder with Chinese characters on a Chinese language Windows machine.
Steps to reproduce:
- Create a Chinese language Windows machine / virtual machine.
- Install Visual Studio.
- Create a folder with any of the following character set in the name: 工, 程, 术, 中, 心. (e.g. D:\心, D:\工)
- Create a new CMake Project inside the folder created in step 3. Once the project is created, modify the
cmake_minimum_required
version to anything past 3.20. This issue does not reproduce with 3.20 as the minimum required version, but reproduces for anything beyond: 3.21, 3.22, etc. - Close Visual Studio and open a Visual Studio developer command prompt (so that cmake.exe is on path).
- cd into the new project directory.
- If VS attempted to configure when you created the project, delete any configure/build output. This is done to ensure that we are only reproducing the command-line behavior and no VS behavior is affecting this.
- Attempt to configure by running
cmake .
.
Note: This also reproduces outside of the VS developer prompt. I only used it in the repro steps for ease of repro and setup. The minimal thing to do is steps 3 and 4 (which can be done outside of VS), ensure you have cmake installed, attempt to configure.
Expected Result:
Configure successfully
Actual Result:
Configure exits early after identifying the compilers and fails to generate the cache.
If you attempt to configure in Visual Studio, you will see something similar to this:
Additional context:
CMake version: 3.28.0
I attached to the cmake configure process using both the VS CMake Debugger and the VS Code CMake Tools Cmake Debugger and found that the configure progress seems to crash and exit at the
find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_FIND_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
line inside of CMakeFindBinUtils.cmake, which on my machine, is at line 224.