diff options
author | Volker Krause <vkrause@kde.org> | 2020-12-10 17:40:22 +0100 |
---|---|---|
committer | Christoph Cullmann <cullmann@kde.org> | 2021-01-02 09:03:08 +0000 |
commit | 59d4958740a09d43aa5025a1cfe3d7b7d4d725b3 (patch) | |
tree | 87e81cc20afcaa928dd56e14200b4660cd5da386 | |
parent | 1af2243e7427ab4454106d883775dee234be01ae (diff) | |
download | extra-cmake-modules-5.78.0-rc1.tar.gz extra-cmake-modules-5.78.0-rc1.tar.bz2 |
Tell MSVC that our source files are UTF-8 encodedv5.78.0-rc1v5.78.0
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.
-rw-r--r-- | kde-modules/KDECompilerSettings.cmake | 7 |
1 files changed, 7 insertions, 0 deletions
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() ############################################################ |