From d6c0e827bc0f49ee6aa6deb5c0ee3838475fe3fe Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 16 May 2023 11:31:26 -0400 Subject: [PATCH] cmGlobalGenerator: add a `QuotedPrintable` method for commands --- Source/cmGlobalGenerator.cxx | 18 ++++++++++++++++++ Source/cmGlobalGenerator.h | 1 + 2 files changed, 19 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3e4d657d40..0e672e6958 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -47,6 +47,7 @@ #include "cmMSVC60LinkLineComputer.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmRange.h" #include "cmSourceFile.h" @@ -73,6 +74,23 @@ const std::string kCMAKE_PLATFORM_INFO_INITIALIZED = class cmInstalledFile; +namespace detail { +std::string GeneratedMakeCommand::QuotedPrintable() const +{ + std::string output; + const char* sep = ""; + int flags = 0; +#if !defined(_WIN32) + flags |= cmOutputConverter::Shell_Flag_IsUnix; +#endif + for (auto const& arg : this->PrimaryCommand) { + output += cmStrCat(sep, cmOutputConverter::EscapeForShell(arg, flags)); + sep = " "; + } + return output; +} +} + bool cmTarget::StrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 79fe52c193..f24465a211 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -85,6 +85,7 @@ struct GeneratedMakeCommand } std::string Printable() const { return cmJoin(this->PrimaryCommand, " "); } + std::string QuotedPrintable() const; std::vector PrimaryCommand; bool RequiresOutputForward = false;