From 59d4958740a09d43aa5025a1cfe3d7b7d4d725b3 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Thu, 10 Dec 2020 17:40:22 +0100 Subject: Tell MSVC that our source files are UTF-8 encoded For GCC/Clang that is the default, but not for MSVC. This can cause both compile-time and runtime errors when encountering string literals that contain more than just 7bit ASCII. Some of our modules set this already, others use various other workarounds to avoid Utf-8 literals, so better do this consistently and centrally. Qt6 will also set this by default. This is actually Hannah's finding from debugging issues caused by this in kitinerary, I'm just submitting the patch. --- kde-modules/KDECompilerSettings.cmake | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'kde-modules/KDECompilerSettings.cmake') diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 63a5ce1f..ebad20eb 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -237,6 +237,13 @@ if (CMAKE_SYSTEM_NAME STREQUAL GNU) set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pthread") endif() +if (MSVC) + # Our source files are UTF-8 encoded, and assuming that is also the + # default behavior of GCC/Clang. Not so for MSVC though, so force + # that to UTF-8 explicitly, as that will otherwise cause compile-time + # and runtime issues when dealing with string literals outside of 7-bit ASCII. + add_compile_options(/utf-8) +endif() ############################################################ -- cgit v1.2.1