windows: msvc: avoid linking to non-redistributable ucrt · ziglang/zig@f5a327c (original) (raw)

Original file line number Diff line number Diff line change
@@ -159,6 +159,16 @@ if(ZIG_STATIC_ZSTD)
159 159 list(APPEND LLVM_LIBRARIES "${ZSTD}")
160 160 endif()
161 161
162 +if (MSVC)
163 + if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
164 + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
165 +# avoid linking to the debug versions of ucrt by default
166 +# as they are not redistributable.
167 +set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
168 + endif()
169 + endif()
170 +endif ()
171 +
162 172 if(ZIG_STATIC_CURSES)
163 173 list(REMOVE_ITEM LLVM_LIBRARIES "-lcurses")
164 174 find_library(CURSES NAMES libcurses.a libncurses.a NAMES_PER_DIR