summaryrefslogtreecommitdiffstats
path: root/Source/cmakemain.cxx
diff options
context:
space:
mode:
authorDāvis Mosāns <davispuh@gmail.com>2016-10-01 00:11:35 (GMT)
committerDāvis Mosāns <davispuh@gmail.com>2016-10-26 14:02:37 (GMT)
commit335a29cb07a8d014a9ed4d4dbf25e49da3a78b33 (patch)
treea49c2857563391c6bd9f1ddd4624f3c3fa85a7df /Source/cmakemain.cxx
parentfdd0ce915c0ab7e5a9f3b95612b35d845a7a5213 (diff)
downloadCMake-335a29cb07a8d014a9ed4d4dbf25e49da3a78b33.zip
CMake-335a29cb07a8d014a9ed4d4dbf25e49da3a78b33.tar.gz
CMake-335a29cb07a8d014a9ed4d4dbf25e49da3a78b33.tar.bz2
Enable Unicode output to Windows consoles
Use KWSys ConsoleBuf to replace the `streambuf` on `std::cout` and `std::cerr` so that process output can be encoded correctly for display in a Windows console.
Diffstat (limited to 'Source/cmakemain.cxx')
-rw-r--r--Source/cmakemain.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index d1159c3..44af966 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -18,6 +18,9 @@
#include <cmConfigure.h>
#include <cmsys/Encoding.hxx>
+#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#include <cmsys/ConsoleBuf.hxx>
+#endif
#include <iostream>
#include <string.h>
#include <string>
@@ -153,6 +156,11 @@ static void cmakemainProgressCallback(const char* m, float prog,
int main(int ac, char const* const* av)
{
+#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+ // Replace streambuf so we can output Unicode to console
+ cmsys::ConsoleBuf::Manager consoleOut(std::cout);
+ cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true);
+#endif
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(ac, av);
ac = args.argc();