diff options
author | Brad King <brad.king@kitware.com> | 2024-09-13 15:49:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-09-16 10:37:46 (GMT) |
commit | e782811cfeb9dc9b7d014f436f778a0ae619129c (patch) | |
tree | 4d04123cc7d4bd76be740cb6be389732c1c45e0a /Source | |
parent | 9a4533405beae781b1dbb68e9273242730c58fdb (diff) | |
download | CMake-e782811cfeb9dc9b7d014f436f778a0ae619129c.zip CMake-e782811cfeb9dc9b7d014f436f778a0ae619129c.tar.gz CMake-e782811cfeb9dc9b7d014f436f778a0ae619129c.tar.bz2 |
execute_process: Change default ENCODING to UTF-8
Windows is heading toward making UTF-8 the preferred MBCS. As CMake's
internal encoding, `UTF-8` is effectively equivalent to `NONE`, which
was CMake's behavior prior to 3.15's accidental change to `AUTO`.
Behavior of `ENCODING UTF-8` is independent of CMake's internal
encoding, making it in principle a better default than `NONE`.
Add policy CMP0176 for compatibility and to document the default's
history.
Fixes: #26262
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExecuteProcessCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmPolicies.h | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index f98228b..97d0afe 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -23,6 +23,7 @@ #include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmPolicies.h" #include "cmProcessOutput.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -297,7 +298,12 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args, }; ReadData outputData; ReadData errorData; - cmProcessOutput::Encoding encoding = cmProcessOutput::Auto; + cmPolicies::PolicyStatus const cmp0176 = + status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0176); + cmProcessOutput::Encoding encoding = + cmp0176 == cmPolicies::OLD || cmp0176 == cmPolicies::WARN + ? cmProcessOutput::Auto + : cmProcessOutput::UTF8; if (arguments.Encoding) { if (cm::optional<cmProcessOutput::Encoding> maybeEncoding = cmProcessOutput::FindEncoding(*arguments.Encoding)) { diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 644cb9e..254c323 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -539,6 +539,8 @@ class cmMakefile; "string after a single-value keyword.", \ 3, 31, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0175, "add_custom_command() rejects invalid arguments.", \ + 3, 31, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0176, "execute_process() ENCODING is UTF-8 by default.", \ 3, 31, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) |