Skip to content

Commit 716e3c7

Browse files
authored
Use CMAKE_MSVC_RUNTIME_LIBRARY to choose MSVC CRT (WebAssembly#7243)
The current approach doesn't work when CMake uses the clang-style version of the flag (i.e. `-MD` instead of `/MD`) to choose the runtime. Now that we are depending on CMake newer than version 3.15 we can use its builtin support for choosing the MSVC runtime.
1 parent d555a06 commit 716e3c7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,11 @@ if(MSVC)
246246
CMAKE_C_FLAGS_MINSIZEREL)
247247
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
248248
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
249-
250-
# Compile with `/MT` to link against `libcmt.lib`, removing a dependency
251-
# on `msvcrt.dll`. May result in slightly larger binaries but they should
252-
# be more portable across systems.
253-
string(REPLACE "/MD" "/MT" ${flags_var_to_scrub} "${${flags_var_to_scrub}}")
254249
endforeach()
250+
# Compile with `/MT` to link against `libcmt.lib`, removing a dependency
251+
# on `msvcrt.dll`. May result in slightly larger binaries but they should
252+
# be more portable across systems.
253+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
255254
endif()
256255

257256
add_link_flag("/STACK:8388608")

0 commit comments

Comments
 (0)