mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 08:08:24 -05:00
Merge topic 'execute_process-encoding'
3898e53e82execute_process: Document and test ENCODING defaultd67519fce8Help/command/execute_process: Improve formatting of ENCODING namese1fc4b9b17Tests/RunCMake/execute_process: Add test for ENCODING AUTO56ae758bc5Tests/RunCMake/execute_process: Improve test for ENCODING UTF-8 Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9816
This commit is contained in:
@@ -140,20 +140,30 @@ Options:
|
||||
``NONE``
|
||||
Perform no decoding. This assumes that the process output is encoded
|
||||
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``
|
||||
Use the current active console's codepage or if that isn't
|
||||
available then use ANSI.
|
||||
|
||||
This is the default since CMake 3.15.
|
||||
|
||||
``ANSI``
|
||||
Use the ANSI codepage.
|
||||
|
||||
``OEM``
|
||||
Use the original equipment manufacturer (OEM) code page.
|
||||
``UTF8`` or ``UTF-8``
|
||||
|
||||
``UTF-8``
|
||||
.. versionadded:: 3.11
|
||||
|
||||
Use the UTF-8 codepage.
|
||||
|
||||
.. versionadded:: 3.11
|
||||
Accept ``UTF-8`` spelling for consistency with the
|
||||
`UTF-8 RFC <https://www.ietf.org/rfc/rfc3629>`_ naming convention.
|
||||
``UTF8``
|
||||
Use the UTF-8 codepage. Use of this name is discouraged in favor
|
||||
of ``UTF-8`` to match the `UTF-8 RFC <https://www.ietf.org/rfc/rfc3629>`_
|
||||
naming convention.
|
||||
|
||||
``COMMAND_ERROR_IS_FATAL <ANY|LAST>``
|
||||
.. versionadded:: 3.19
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
if(ENCODING)
|
||||
set(maybe_ENCODING ENCODING ${ENCODING})
|
||||
else()
|
||||
set(maybe_ENCODING "")
|
||||
set(ENCODING AUTO) # execute_process's default ENCODING
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${TEST_ENCODING_EXE} ${ENCODING} ${CMAKE_CURRENT_LIST_DIR}/Encoding${ENCODING}-stderr.txt
|
||||
OUTPUT_VARIABLE out
|
||||
${maybe_ENCODING}
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
# Set the console code page.
|
||||
execute_process(COMMAND cmd /c chcp ${CODEPAGE})
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Encoding-common.cmake)
|
||||
|
||||
# Save our internal UTF-8 representation of the output.
|
||||
file(WRITE "out.txt" "${out}")
|
||||
@@ -1,6 +1,14 @@
|
||||
execute_process(
|
||||
COMMAND ${TEST_ENCODING_EXE} ${TEST_ENCODING} ${CMAKE_CURRENT_LIST_DIR}/EncodingUTF8-stderr.txt
|
||||
OUTPUT_VARIABLE out
|
||||
ENCODING ${TEST_ENCODING}
|
||||
)
|
||||
if(CMAKE_HOST_WIN32 AND CODEPAGE)
|
||||
# Run cmake in a new Window to isolate its console code page.
|
||||
execute_process(COMMAND cmd /c start /min /wait ""
|
||||
${CMAKE_COMMAND} -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE}
|
||||
-DENCODING=${ENCODING}
|
||||
-DCODEPAGE=${CODEPAGE}
|
||||
-P ${CMAKE_CURRENT_LIST_DIR}/Encoding-windows.cmake)
|
||||
|
||||
# Load our internal UTF-8 representation of the output.
|
||||
file(READ "out.txt" out)
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Encoding-common.cmake)
|
||||
endif()
|
||||
message("${out}")
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Chinese
|
||||
注意
|
||||
@@ -0,0 +1,3 @@
|
||||
set(ENCODING AUTO)
|
||||
set(CODEPAGE 54936)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
|
||||
@@ -0,0 +1,2 @@
|
||||
Chinese
|
||||
注意
|
||||
@@ -0,0 +1,3 @@
|
||||
# No explicit ENCODING option; fall back to default.
|
||||
set(CODEPAGE 54936)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
|
||||
@@ -1 +1,2 @@
|
||||
यूनिकोड είναι very здорово!
|
||||
Chinese Hindi Greek English Russian
|
||||
注意 यूनिकोड είναι very здорово!
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
set(ENCODING UTF-8)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
|
||||
@@ -1 +1,2 @@
|
||||
यूनिकोड είναι very здорово!
|
||||
Chinese Hindi Greek English Russian
|
||||
注意 यूनिकोड είναι very здорово!
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
set(ENCODING UTF8)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
|
||||
@@ -9,8 +9,10 @@ run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/Mer
|
||||
|
||||
run_cmake(EncodingMissing)
|
||||
if(TEST_ENCODING_EXE)
|
||||
run_cmake_command(EncodingUTF8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake)
|
||||
run_cmake_command(EncodingUTF-8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF-8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake)
|
||||
run_cmake_script(EncodingDefault -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(EncodingUTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
|
||||
endif()
|
||||
|
||||
if(EXIT_CODE_EXE)
|
||||
|
||||
Reference in New Issue
Block a user