summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-08-23 15:09:17 (GMT)
committerBrad King <brad.king@kitware.com>2017-08-23 15:10:41 (GMT)
commitde9840d1b89481132ee128715506f6aee9d0277c (patch)
tree817d9dd185467473c3be2e762225be30670df255
parentfca4423786ba2c4a5ab0ec6c1a1cbac8cd8600b4 (diff)
downloadCMake-de9840d1b89481132ee128715506f6aee9d0277c.zip
CMake-de9840d1b89481132ee128715506f6aee9d0277c.tar.gz
CMake-de9840d1b89481132ee128715506f6aee9d0277c.tar.bz2
Ninja: Fix support for MSVC with non-English output
With MSVC the Ninja generator extracts the `cl -showIncludes` prefix. When MSVC is configured to have non-English output, e.g. via `VSLANG=2052` in the environment, then `cl` prints the prefix encoded for the current code page, which is not necessarily UTF-8 encoding. Currently we fail to convert the prefix to our internal UTF-8 encoding, but assume it is UTF-8 later. While writing `rules.ninja`, the Ninja generator converts our internal UTF-8 encoding to the current code page. The `msvc_deps_prefix =` line needs to be encoded as the current code page so that `ninja` can match in the output from `cl -showIncludes` during the build. Prior to commit v3.9.0-rc1~47^2 (codecvt: Re-implement do_out and do_unshift, 2017-05-25), the non-UTF-8 prefix extracted above was written without noticing its incorrect internal encoding. The `rules.ninja` file was successfully written, but possibly with a mangled `msvc_deps_prefix`. Since that commit the output stream correctly rejects the non-UTF-8 byte sequence and writing `rules.ninja` fails. Fix this by correctly converting the `cl -showIncludes` output from the current code page to our internal UTF-8 encoding. Fixes: #17191
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake1
1 files changed, 1 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index eeb806f..7588f63 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -706,6 +706,7 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags)
OUTPUT_VARIABLE out
ERROR_VARIABLE err
RESULT_VARIABLE res
+ ENCODING AUTO # cl prints in current code page
)
if(res EQUAL 0 AND "${out}" MATCHES "(^|\n)([^:\n]*:[^:\n]*:[ \t]*)")
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_MATCH_2}" PARENT_SCOPE)