summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-09-13 15:49:50 (GMT)
committerBrad King <brad.king@kitware.com>2024-09-16 10:37:46 (GMT)
commite782811cfeb9dc9b7d014f436f778a0ae619129c (patch)
tree4d04123cc7d4bd76be740cb6be389732c1c45e0a /Tests/RunCMake
parent9a4533405beae781b1dbb68e9273242730c58fdb (diff)
downloadCMake-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 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/execute_process/Encoding-common.cmake7
-rw-r--r--Tests/RunCMake/execute_process/Encoding-windows.cmake4
-rw-r--r--Tests/RunCMake/execute_process/Encoding.cmake3
-rw-r--r--Tests/RunCMake/execute_process/EncodingCMP0176-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/execute_process/EncodingCMP0176-NEW.cmake3
-rw-r--r--Tests/RunCMake/execute_process/EncodingCMP0176-OLD-stderr.txt (renamed from Tests/RunCMake/execute_process/EncodingDefault-stderr.txt)0
-rw-r--r--Tests/RunCMake/execute_process/EncodingCMP0176-OLD.cmake (renamed from Tests/RunCMake/execute_process/EncodingDefault.cmake)1
-rw-r--r--Tests/RunCMake/execute_process/RunCMakeTest.cmake3
8 files changed, 21 insertions, 2 deletions
diff --git a/Tests/RunCMake/execute_process/Encoding-common.cmake b/Tests/RunCMake/execute_process/Encoding-common.cmake
index e13be75..fda1c2d 100644
--- a/Tests/RunCMake/execute_process/Encoding-common.cmake
+++ b/Tests/RunCMake/execute_process/Encoding-common.cmake
@@ -2,7 +2,12 @@ if(ENCODING)
set(maybe_ENCODING ENCODING ${ENCODING})
else()
set(maybe_ENCODING "")
- set(ENCODING AUTO) # execute_process's default ENCODING
+ cmake_policy(GET CMP0176 cmp0176)
+ if(cmp0176 STREQUAL "NEW")
+ set(ENCODING UTF-8) # execute_process's default ENCODING
+ else()
+ set(ENCODING AUTO) # execute_process's default ENCODING
+ endif()
endif()
execute_process(
COMMAND ${TEST_ENCODING_EXE} ${ENCODING} ${CMAKE_CURRENT_LIST_DIR}/Encoding${ENCODING}-stderr.txt
diff --git a/Tests/RunCMake/execute_process/Encoding-windows.cmake b/Tests/RunCMake/execute_process/Encoding-windows.cmake
index 69b9bc7..d51589c 100644
--- a/Tests/RunCMake/execute_process/Encoding-windows.cmake
+++ b/Tests/RunCMake/execute_process/Encoding-windows.cmake
@@ -1,3 +1,7 @@
+if(CMP0176 STREQUAL "NEW")
+ cmake_policy(SET CMP0176 NEW)
+endif()
+
# Set the console code page.
execute_process(COMMAND cmd /c chcp ${CODEPAGE})
diff --git a/Tests/RunCMake/execute_process/Encoding.cmake b/Tests/RunCMake/execute_process/Encoding.cmake
index 206a71b..61d2c22 100644
--- a/Tests/RunCMake/execute_process/Encoding.cmake
+++ b/Tests/RunCMake/execute_process/Encoding.cmake
@@ -1,9 +1,12 @@
if(CMAKE_HOST_WIN32 AND CODEPAGE)
+ cmake_policy(GET CMP0176 CMP0176)
+
# 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}
+ -DCMP0176=${CMP0176}
-P ${CMAKE_CURRENT_LIST_DIR}/Encoding-windows.cmake)
# Load our internal UTF-8 representation of the output.
diff --git a/Tests/RunCMake/execute_process/EncodingCMP0176-NEW-stderr.txt b/Tests/RunCMake/execute_process/EncodingCMP0176-NEW-stderr.txt
new file mode 100644
index 0000000..9fd0dcd
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EncodingCMP0176-NEW-stderr.txt
@@ -0,0 +1,2 @@
+Chinese Hindi Greek English Russian
+注意 यूनिकोड είναι very здорово!
diff --git a/Tests/RunCMake/execute_process/EncodingCMP0176-NEW.cmake b/Tests/RunCMake/execute_process/EncodingCMP0176-NEW.cmake
new file mode 100644
index 0000000..b23ff59
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EncodingCMP0176-NEW.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0176 NEW)
+# No explicit ENCODING option; fall back to default.
+include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
diff --git a/Tests/RunCMake/execute_process/EncodingDefault-stderr.txt b/Tests/RunCMake/execute_process/EncodingCMP0176-OLD-stderr.txt
index b4cf27a..b4cf27a 100644
--- a/Tests/RunCMake/execute_process/EncodingDefault-stderr.txt
+++ b/Tests/RunCMake/execute_process/EncodingCMP0176-OLD-stderr.txt
diff --git a/Tests/RunCMake/execute_process/EncodingDefault.cmake b/Tests/RunCMake/execute_process/EncodingCMP0176-OLD.cmake
index 60b1eb6..8057176 100644
--- a/Tests/RunCMake/execute_process/EncodingDefault.cmake
+++ b/Tests/RunCMake/execute_process/EncodingCMP0176-OLD.cmake
@@ -1,3 +1,4 @@
+cmake_policy(SET CMP0176 OLD)
# No explicit ENCODING option; fall back to default.
set(CODEPAGE 54936)
include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
index b3ebdca..2516de0 100644
--- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake
+++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
@@ -9,7 +9,8 @@ run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/Mer
run_cmake(EncodingMissing)
if(TEST_ENCODING_EXE)
- run_cmake_script(EncodingDefault -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
+ run_cmake_script(EncodingCMP0176-NEW -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
+ run_cmake_script(EncodingCMP0176-OLD -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})