Skip to content

Commit 12e0773

Browse files
compnerdLukasa
andauthored
build: support building in Debug mode on Windows (#153)
With this tweak, we should be able to build the package in debug mode even on Windows. We always use the release mode DLL form of the C/C++ runtime on Windows and can build the Swift code in Debug or Release mode optimizations. Co-authored-by: Cory Benfield <[email protected]>
1 parent 4ff26ad commit 12e0773

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
##
1313
##===----------------------------------------------------------------------===##
1414

15+
if(POLICY CMP0091)
16+
cmake_policy(SET CMP0091 NEW)
17+
endif()
18+
1519
cmake_minimum_required(VERSION 3.19)
1620

1721
project(SwiftCertificates
@@ -21,22 +25,20 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
2125

2226
include(SwiftSupport)
2327

28+
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
29+
2430
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2531
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2632
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2733

34+
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
2835
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
2936

30-
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
31-
32-
if(BUILD_SHARED_LIBS)
33-
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
34-
endif()
37+
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
38+
set(CMAKE_POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS})
3539

36-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
37-
find_package(dispatch CONFIG)
38-
find_package(Foundation CONFIG)
39-
endif()
40+
find_package(dispatch CONFIG)
41+
find_package(Foundation CONFIG)
4042

4143
find_package(SwiftASN1 CONFIG REQUIRED)
4244
find_package(SwiftCrypto CONFIG REQUIRED)

0 commit comments

Comments
 (0)