diff options
author | Brad King <brad.king@kitware.com> | 2020-10-15 12:10:40 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-10-15 12:10:50 (GMT) |
commit | b1d9a25f35a22f41b2c1b87725f091936711a28c (patch) | |
tree | c2196fa3b431f21af857fe830928fe2f28979220 /Source/cmakemain.cxx | |
parent | 30643e21d48004c6d5675d14881ad82ace1194b7 (diff) | |
parent | f7a5f283188c1e51b0fb549f0a78afaf1d570383 (diff) | |
download | CMake-b1d9a25f35a22f41b2c1b87725f091936711a28c.zip CMake-b1d9a25f35a22f41b2c1b87725f091936711a28c.tar.gz CMake-b1d9a25f35a22f41b2c1b87725f091936711a28c.tar.bz2 |
Merge topic 'cmake-E-cat-binary' into release-3.19
f7a5f28318 cmake: Fix '-E cat' command for binary files on Windows
90b39a5209 cmConsoleBuf: Factor out cout/cerr console buffer management
f1fdd15863 clang-format: Fix include block order in ctest.cxx and cpack.cxx
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5364
Diffstat (limited to 'Source/cmakemain.cxx')
-rw-r--r-- | Source/cmakemain.cxx | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index c769227..f570337 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -11,12 +11,15 @@ #include <iostream> #include <sstream> #include <string> +#include <utility> #include <vector> +#include <cm/memory> #include <cmext/algorithm> #include <cm3p/uv.h> +#include "cmConsoleBuf.h" #include "cmDocumentationEntry.h" // IWYU pragma: keep #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -34,9 +37,6 @@ #endif #include "cmsys/Encoding.hxx" -#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) -# include "cmsys/ConsoleBuf.hxx" -#endif namespace { #ifndef CMAKE_BOOTSTRAP @@ -111,13 +111,14 @@ const char* cmDocumentationOptions[][2] = { #endif -int do_command(int ac, char const* const* av) +int do_command(int ac, char const* const* av, + std::unique_ptr<cmConsoleBuf> consoleBuf) { std::vector<std::string> args; args.reserve(ac - 1); args.emplace_back(av[0]); cm::append(args, av + 2, av + ac); - return cmcmd::ExecuteCMakeCommand(args); + return cmcmd::ExecuteCMakeCommand(args, std::move(consoleBuf)); } cmMakefile* cmakemainGetMakefile(cmake* cm) @@ -830,13 +831,11 @@ int do_open(int ac, char const* const* av) int main(int ac, char const* const* av) { cmSystemTools::EnsureStdPipes(); -#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) + // Replace streambuf so we can output Unicode to console - cmsys::ConsoleBuf::Manager consoleOut(std::cout); - consoleOut.SetUTF8Pipes(); - cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true); - consoleErr.SetUTF8Pipes(); -#endif + auto consoleBuf = cm::make_unique<cmConsoleBuf>(); + consoleBuf->SetUTF8Pipes(); + cmsys::Encoding::CommandLineArguments args = cmsys::Encoding::CommandLineArguments::Main(ac, av); ac = args.argc(); @@ -855,7 +854,7 @@ int main(int ac, char const* const* av) return do_open(ac, av); } if (strcmp(av[1], "-E") == 0) { - return do_command(ac, av); + return do_command(ac, av, std::move(consoleBuf)); } } int ret = do_cmake(ac, av); |