Skip to content

Commit fdf0fa2

Browse files
committed
build: improve debug builds on Windows
Ensure that we build all the target libraries with the correct build configuration. This is needed on Windows where the different MSVC runtime libraries are ABI incompatible.
1 parent 5467232 commit fdf0fa2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,20 @@ function(add_swift_target_library name)
19141914
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
19151915
)
19161916

1917+
if(sdk STREQUAL WINDOWS)
1918+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
1919+
if (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebugDLL)
1920+
target_compile_options(${VARIANT_NAME} PRIVATE /MDd /D_DLL /D_DEBUG)
1921+
elseif (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebug)
1922+
target_compile_options(${VARIANT_NAME} PRIVATE /MTd /U_DLL /D_DEBUG)
1923+
elseif (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDLL)
1924+
target_compile_options(${VARIANT_NAME} PRIVATE /MD /D_DLL /U_DEBUG)
1925+
elseif (SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY MATCHES MultiThreaded)
1926+
target_compile_options(${VARIANT_NAME} PRIVATE /MT /U_DLL /U_DEBUG)
1927+
endif()
1928+
endif()
1929+
endif()
1930+
19171931
if(NOT SWIFTLIB_OBJECT_LIBRARY)
19181932
# Add dependencies on the (not-yet-created) custom lipo target.
19191933
foreach(DEP ${SWIFTLIB_LINK_LIBRARIES})

0 commit comments

Comments
 (0)