mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 03:39:43 -06:00
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
17 lines
464 B
CMake
17 lines
464 B
CMake
if(ENCODING)
|
|
set(maybe_ENCODING ENCODING ${ENCODING})
|
|
else()
|
|
set(maybe_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
|
|
OUTPUT_VARIABLE out
|
|
${maybe_ENCODING}
|
|
)
|