Link against (non-debug) MSVC runtime statically

This commit is contained in:
ISSOtm
2026-05-14 02:44:11 +02:00
committed by Eldred Habert
parent fee177d0b9
commit d5186b088b
+9
View File
@@ -40,6 +40,15 @@ include(CMakeDependentOption)
option(SANITIZERS "Build with sanitizers enabled" OFF)
cmake_dependent_option(MORE_WARNINGS "Turn on more warnings" OFF "NOT MSVC" OFF)
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) # Allow this to be overridden from the CLI easily.
# We link against the Microsoft C++ runtime libs statically, except the debug-mode one.
# This is because Microsoft's license terms (through some indirection) allow us to redistribute
# the runtime lib code *except* the debug-mode libs'.
# Since we want to remain able to not think too hard about debug executables, we link against
# the debug libs dynamically, shifting the burden of obtaining them onto the recipient.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:DebugDLL>")
endif()
if(SANITIZERS)
if(MSVC)
message(STATUS "ASan enabled")