Skip to content

Commit 8625b71

Browse files
authored
Merge pull request #24664 from compnerd/threading-now-you-have-two-problems
build: correct flags for Windows build
2 parents 9c4c304 + cd0c1e7 commit 8625b71

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,13 @@ function(_add_variant_c_compile_flags)
230230

231231
if("${CFLAGS_SDK}" STREQUAL "WINDOWS")
232232
# MSVC doesn't support -Xclang. We don't need to manually specify
233-
# -D_MD or D_MDd either, as CMake does this automatically.
233+
# the dependent libraries as `cl` does so.
234234
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
235235
list(APPEND result -Xclang;--dependent-lib=oldnames)
236236
# TODO(compnerd) handle /MT, /MTd
237237
if("${CFLAGS_BUILD_TYPE}" STREQUAL "Debug")
238-
list(APPEND result "-D_MDd")
239238
list(APPEND result -Xclang;--dependent-lib=msvcrtd)
240239
else()
241-
list(APPEND result "-D_MD")
242240
list(APPEND result -Xclang;--dependent-lib=msvcrt)
243241
endif()
244242
endif()
@@ -260,6 +258,7 @@ function(_add_variant_c_compile_flags)
260258
if("${CFLAGS_ARCH}" MATCHES arm)
261259
list(APPEND result "-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE")
262260
endif()
261+
list(APPEND result "-D_MT")
263262
# TODO(compnerd) handle /MT
264263
list(APPEND result "-D_DLL")
265264
# NOTE: We assume that we are using VS 2015 U2+
@@ -401,6 +400,12 @@ function(_add_variant_swift_compile_flags
401400
list(APPEND result "-D" "SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS")
402401
endif()
403402

403+
if(sdk STREQUAL WINDOWS)
404+
list(APPEND result "-Xcc" "-D_MT")
405+
# TODO(compnerd) handle /MT /MTd
406+
list(APPEND result "-Xcc" "-D_DLL")
407+
endif()
408+
404409
set("${result_var_name}" "${result}" PARENT_SCOPE)
405410
endfunction()
406411

0 commit comments

Comments
 (0)