build: set /utf-8 flag when using MSVC (#4975)
MSVC by default decodes source files in the current Windows code page if they don't have a Unicode BOM, and also encodes strings and chars into the current code page before storing them into the compiled binary. Our files are always encoded in UTF-8, and our code always assumes runtime strings are encoded in UTF-8, so we should pass the `/utf-8` flag to MSVC. Microsoft Docs: https://learn.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8
This commit is contained in:
parent
9d1a141482
commit
e2b6dc48b1
|
@ -181,6 +181,8 @@ if(WIN32)
|
|||
# Ignore various deprecation and security warnings (at least for now)
|
||||
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS")
|
||||
if(MSVC)
|
||||
# Set source file encoding and execution charset to UTF-8
|
||||
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} /utf-8")
|
||||
# Reduce noise (at least for now)
|
||||
set(CMAKE_${L}_FLAGS "${CMAKE_${L}_FLAGS} /wd4244 /wd4267")
|
||||
# Make caching-friendly (store debug info inside object files)
|
||||
|
|
Loading…
Reference in New Issue