From f5a327cd366348a739a282f380acd627815183b5 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Tue, 17 Jun 2025 13:40:25 -0600 Subject: [PATCH] windows: msvc: avoid linking to non-redistributable ucrt --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d5c5cfbe..13f777245f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,6 +159,16 @@ if(ZIG_STATIC_ZSTD) list(APPEND LLVM_LIBRARIES "${ZSTD}") endif() +if (MSVC) + if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + # avoid linking to the debug versions of ucrt by default + # as they are not redistributable. + set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) + endif() + endif() +endif () + if(ZIG_STATIC_CURSES) list(REMOVE_ITEM LLVM_LIBRARIES "-lcurses") find_library(CURSES NAMES libcurses.a libncurses.a NAMES_PER_DIR