diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 58fe544d..5a1425fc 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -157,6 +157,9 @@ if(BUILD_TESTING) add_test(NAME segmentation_contract COMMAND test_segmentation_contract) add_executable(test_windows_ipc_contract contracts/tests/windows_ipc_contract.cpp) + if(MSVC) + target_compile_options(test_windows_ipc_contract PRIVATE /utf-8) + endif() add_test(NAME windows_ipc_contract COMMAND test_windows_ipc_contract) add_executable(test_punctuation_contract contracts/tests/punctuation_contract.cpp) diff --git a/server/tests/portable/CMakeLists.txt b/server/tests/portable/CMakeLists.txt index 7d8c6692..542057af 100644 --- a/server/tests/portable/CMakeLists.txt +++ b/server/tests/portable/CMakeLists.txt @@ -32,7 +32,10 @@ if(MSIME_PORTABLE_TESTS_SANITIZE AND NOT MSVC) target_link_options(portable_tests PRIVATE -fsanitize=address,undefined) endif() -if(NOT MSVC) +if(MSVC) + # Standalone project, so the server's directory-wide /utf-8 does not reach it. + target_compile_options(portable_tests PRIVATE /utf-8) +else() target_compile_options(portable_tests PRIVATE -Wall -Wextra -Wpedantic -Werror) endif() diff --git a/tests/pipe-probe/CMakeLists.txt b/tests/pipe-probe/CMakeLists.txt index 9ac39505..b89c5c47 100644 --- a/tests/pipe-probe/CMakeLists.txt +++ b/tests/pipe-probe/CMakeLists.txt @@ -8,3 +8,6 @@ add_executable(msime-ipc-probe main.cpp) target_compile_features(msime-ipc-probe PRIVATE cxx_std_17) target_compile_definitions(msime-ipc-probe PRIVATE NOMINMAX UNICODE _UNICODE) target_include_directories(msime-ipc-probe PRIVATE "${MSIME_CONTRACTS_DIR}") +if(MSVC) + target_compile_options(msime-ipc-probe PRIVATE /utf-8) +endif() diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index ebaab879..ce64f633 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -143,6 +143,9 @@ target_link_libraries(msimeui-handwriting-demo PRIVATE msimeui windowsapp.lib) target_compile_features(msimeui-handwriting-demo PRIVATE cxx_std_20) if(MSVC) + # include/msimeui/Controls.h is UTF-8 without a BOM, so every consumer of msimeui has to read + # it as UTF-8 too; otherwise a CJK-locale build (code page 936) swallows lines and fails. + target_compile_options(msimeui PUBLIC /utf-8) target_compile_options(msimeui PRIVATE /W4 /permissive-) target_compile_options(msimeui-demo PRIVATE /W4 /permissive-) target_compile_options(msimeui-emoji-panel PRIVATE /W4 /permissive-) diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 4e3e3b07..04ea68b8 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -13,6 +13,9 @@ project(${PROJECT_NAME} LANGUAGES CXX C) # Release binaries need usable symbols for crash diagnosis. Keep the PDB beside the DLL so the # release job can validate and publish it without changing the binary's install layout. if(MSVC) + # Sources are UTF-8 without a BOM and hold wide punctuation literals (L"“" and the like). /utf-8 + # used to arrive only through fmt's interface options, which the tests below never link. + add_compile_options(/utf-8) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase") add_compile_options("$<$:/Zi>") add_link_options("$<$:/DEBUG>") diff --git a/windows/tests/CMakeLists.txt b/windows/tests/CMakeLists.txt index 6a44dc6f..e3e2b506 100644 --- a/windows/tests/CMakeLists.txt +++ b/windows/tests/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 3.25) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(MsimeTsfLocalPolicyTests LANGUAGES CXX) enable_testing() + # windows/CMakeLists.txt sets this for the in-tree build; the sources and headers are UTF-8. + if(MSVC) + add_compile_options(/utf-8) + endif() endif() add_executable(test_client_fallback client_fallback.cpp)