Skip to content

Commit

Permalink
build: support building in Debug mode on Windows (#153)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
compnerd and Lukasa authored Dec 1, 2023
1 parent 4ff26ad commit 12e0773
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
##
##===----------------------------------------------------------------------===##

if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

cmake_minimum_required(VERSION 3.19)

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

include(SwiftSupport)

option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)

if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
endif()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
set(CMAKE_POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS})

if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
find_package(dispatch CONFIG)
find_package(Foundation CONFIG)
endif()
find_package(dispatch CONFIG)
find_package(Foundation CONFIG)

find_package(SwiftASN1 CONFIG REQUIRED)
find_package(SwiftCrypto CONFIG REQUIRED)
Expand Down

0 comments on commit 12e0773

Please sign in to comment.