Skip to content

Commit 004d0b9

Browse files
authored
Merge pull request swiftlang#19279 from compnerd/msbuild
2 parents c4a6a09 + d9dde28 commit 004d0b9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cmake/modules/ClangClCompileRules.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

22
# clang-cl interprets paths starting with /U as macro undefines, so we need to
33
# put a -- before the input file path to force it to be treated as a path.
4-
string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
5-
string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
4+
if(NOT MSVC AND "${CMAKE_SIMULATE_ID}" STREQUAL "MSVC")
5+
string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
6+
string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
7+
endif()
68

79
# NOTE(compnerd) incremental linking is known to cause corruption in the
810
# protocol conformance tables. Avoid using incremental links with Visual

cmake/modules/SwiftSharedCMakeConfig.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ endmacro()
270270
macro(swift_common_cxx_warnings)
271271
# Make unhandled switch cases be an error in assert builds
272272
if(DEFINED LLVM_ENABLE_ASSERTIONS)
273-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=switch")
273+
check_cxx_compiler_flag("-Werror=switch" CXX_SUPPORTS_WERROR_SWITCH_FLAG)
274+
append_if(CXX_SUPPORTS_WERROR_SWITCH_FLAG "-Werror=switch" CMAKE_CXX_FLAGS)
275+
276+
check_cxx_compiler_flag("/we4062" CXX_SUPPORTS_WE4062)
277+
append_if(CXX_SUPPORTS_WE4062 "/we4062" CMAKE_CXX_FLAGS)
274278
endif()
275279

276280
check_cxx_compiler_flag("-Werror -Wdocumentation" CXX_SUPPORTS_DOCUMENTATION_FLAG)

0 commit comments

Comments
 (0)