From b7e7718a38194879a43bce580ad5e831621ded91 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Fri, 3 Aug 2018 13:53:08 -0700 Subject: MSVC: Fix manifest resource encoding When using the Ninja or Makefile generator with MSVC on Windows we invoke the resource compiler (`rc.exe`) to compile a manifest resource. CMake generates the file with UTF-8 encoding so we need to add a pragma to inform the resource compiler. --- Source/cmcmd.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 0a75e77..2fd1a84 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1775,6 +1775,8 @@ int cmVSLink::LinkIncremental() if (!fout) { return -1; } + // Insert a pragma statement to specify utf-8 encoding. + fout << "#pragma code_page(65001)\n"; fout << this->Type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ " "24 /* RT_MANIFEST */ \"" -- cgit v0.12 From 7e359823c9cd5bf162e3e62561328607d4449a59 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Fri, 3 Aug 2018 13:53:08 -0700 Subject: 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. --- Source/cmcmd.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 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; } -- cgit v0.12