@@ -23,6 +23,37 @@ set(MFILE_ARGS
2323 "--compiler=${compiler} "
2424)
2525
26+ # XED is built by mbuild, not CMake, so it does not honor
27+ # CMAKE_MSVC_RUNTIME_LIBRARY. mbuild also ties "--static" to /MT by default.
28+ # Dna.LLVMInterop and the CMake-built dependencies use the DLL CRT (/MD), so
29+ # disable mbuild's implicit CRT flag and pass the matching MSVC runtime flag
30+ # explicitly. Without this, xed.lib/xed-ild.lib embed /DEFAULTLIB:libcmt.lib
31+ # and the Dna.LLVMInterop link emits LNK4098.
32+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND MSVC )
33+ set (xed_msvc_runtime_flag "" )
34+ if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY AND NOT CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "" )
35+ if (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DebugDLL$" )
36+ set (xed_msvc_runtime_flag "/MDd" )
37+ elseif (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$" )
38+ set (xed_msvc_runtime_flag "/MD" )
39+ elseif (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug$" )
40+ set (xed_msvc_runtime_flag "/MTd" )
41+ else ()
42+ set (xed_msvc_runtime_flag "/MT" )
43+ endif ()
44+ elseif (CMAKE_BUILD_TYPE STREQUAL "Debug" )
45+ set (xed_msvc_runtime_flag "/MDd" )
46+ else ()
47+ set (xed_msvc_runtime_flag "/MD" )
48+ endif ()
49+
50+ list (APPEND MFILE_ARGS
51+ "--no-mscrt"
52+ "--extra-ccflags=${xed_msvc_runtime_flag} "
53+ "--extra-cxxflags=${xed_msvc_runtime_flag} "
54+ )
55+ endif ()
56+
2657if (CMAKE_OSX_SYSROOT)
2758 list (APPEND MFILE_ARGS "--extra-ccflags=-isysroot ${CMAKE_OSX_SYSROOT} " )
2859 list (APPEND MFILE_ARGS "--extra-cxxflags=-isysroot ${CMAKE_OSX_SYSROOT} " )
0 commit comments