diff options
author | Justin Goshi <jgoshi@microsoft.com> | 2018-08-03 20:53:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-08-09 15:06:12 (GMT) |
commit | 7e359823c9cd5bf162e3e62561328607d4449a59 (patch) | |
tree | 0dd05b2d6cf1a1bc00481620bf36b977e3031c76 /Source/cmcmd.cxx | |
parent | b7e7718a38194879a43bce580ad5e831621ded91 (diff) | |
download | CMake-7e359823c9cd5bf162e3e62561328607d4449a59.zip CMake-7e359823c9cd5bf162e3e62561328607d4449a59.tar.gz CMake-7e359823c9cd5bf162e3e62561328607d4449a59.tar.bz2 |
MSVC: Preserve linker output encoding
When using the Ninja or Makefile generator with MSVC on Windows
we invoke the linker through a `cmake -E vs_link_{exe,dll}` wrapper.
Preserve the linker output encoding to match `link.exe` behavior
instead of forcing UTF-8.
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 2fd1a84..2027722 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -24,6 +24,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) # include "bindexplib.h" +# include "cmsys/ConsoleBuf.hxx" #endif #if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__) @@ -1545,6 +1546,15 @@ private: // still works. int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type) { +#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) + // Replace streambuf so we output in the system codepage. CMake is set up + // to output in Unicode (see SetUTF8Pipes) but the Visual Studio linker + // outputs using the system codepage so we need to change behavior when + // we run the link command. + cmsys::ConsoleBuf::Manager consoleOut(std::cout); + cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true); +#endif + if (args.size() < 2) { return -1; } |