Browse Source

execute_process: Document and test ENCODING default

The default was originally AUTO in commit 2ed473b3b8 (execute_process:
Add ENCODING option for Windows child process output, 2016-11-23,
v3.8.0-rc1~232^2) but was changed back to NONE by commit 07c3380a6e
(execute_process: Restore no-decoding default behavior, 2017-02-13,
v3.8.0-rc2~26^2) for CMake 3.8.  Later it was accidentally changed back
to AUTO by commit b783e62533 (cmExecuteProcessCommand: Port to
cmArgumentParser, 2019-03-25, v3.15.0-rc1~270^2) in CMake 3.15 but the
documentation was not updated.  Document the current default, AUTO, and
add a test case to verify it.

Issue: #26262
Brad King 1 year ago
parent
commit
3898e53e82

+ 4 - 1
Help/command/execute_process.rst

@@ -140,12 +140,15 @@ Options:
  ``NONE``
  ``NONE``
    Perform no decoding.  This assumes that the process output is encoded
    Perform no decoding.  This assumes that the process output is encoded
    in the same way as CMake's internal encoding (UTF-8).
    in the same way as CMake's internal encoding (UTF-8).
-   This is the default.
+
+   This was the default in CMake 3.14 and older.
 
 
  ``AUTO``
  ``AUTO``
    Use the current active console's codepage or if that isn't
    Use the current active console's codepage or if that isn't
    available then use ANSI.
    available then use ANSI.
 
 
+   This is the default since CMake 3.15.
+
  ``ANSI``
  ``ANSI``
    Use the ANSI codepage.
    Use the ANSI codepage.
 
 

+ 2 - 0
Tests/RunCMake/execute_process/EncodingDefault-stderr.txt

@@ -0,0 +1,2 @@
+Chinese
+注意

+ 3 - 0
Tests/RunCMake/execute_process/EncodingDefault.cmake

@@ -0,0 +1,3 @@
+# No explicit ENCODING option; fall back to default.
+set(CODEPAGE 54936)
+include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)

+ 1 - 0
Tests/RunCMake/execute_process/RunCMakeTest.cmake

@@ -9,6 +9,7 @@ run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/Mer
 
 
 run_cmake(EncodingMissing)
 run_cmake(EncodingMissing)
 if(TEST_ENCODING_EXE)
 if(TEST_ENCODING_EXE)
+  run_cmake_script(EncodingDefault -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
   run_cmake_script(EncodingAUTO -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
   run_cmake_script(EncodingAUTO -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
   run_cmake_script(EncodingUTF-8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
   run_cmake_script(EncodingUTF-8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
   run_cmake_script(EncodingUTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
   run_cmake_script(EncodingUTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})