Skip to content

Commit 5437569

Browse files
committed
build: enable building in Debug mode on Windows
Windows does not have an ABI stable C/C++ runtime, and is ABI incompatible between debug and release mode on the same version even. Ensure that we always use the release mode DLL variant of the C/C++ runtime (`/MD`) allowing us to build the client code in debug or release mode.
1 parent d6d5608 commit 5437569

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9+
if(POLICY CMP0091)
10+
cmake_policy(SET CMP0091 NEW)
11+
endif()
12+
913
cmake_minimum_required(VERSION 3.19.6)
1014

1115
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
@@ -14,12 +18,14 @@ project(SwiftDriver LANGUAGES C Swift)
1418

1519
set(CMAKE_Swift_LANGUAGE_VERSION 5)
1620
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
21+
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
1722

1823
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1924
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2025
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2126

2227
set(CMAKE_MACOSX_RPATH YES)
28+
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
2329

2430
# ensure Swift compiler can find _CSwiftScan
2531
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-I$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/Sources/CSwiftScan/include>)

0 commit comments

Comments
 (0)