Skip to content

build: use the new -libc flag for Windows #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ cmake_minimum_required(VERSION 3.4.3)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

# NOTE(compnerd) enable CMP0091 - select MSVC Runtime Library via the
# CMAKE_MSVC_RUNTIME_LIBRARY setting
if(POLICY CMP0091)
cmake_policy(CMP0091 NEW)
endif()

project(dispatch
VERSION 1.3
LANGUAGES C CXX)
Expand All @@ -19,6 +25,9 @@ set(CMAKE_CXX_STANDARD 11)

set(CMAKE_C_VISIBILITY_PRESET hidden)

# NOTE(compnerd) default to /MD or /MDd based on the configuration on Windows
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
Expand Down
8 changes: 1 addition & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ if(ENABLE_SWIFT)
-lBlocksRuntime
-L $<TARGET_LINKER_FILE_DIR:dispatch>
-ldispatch
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:Debug>>:-lmsvcrtd>
$<$<AND:$<PLATFORM_ID:Windows>,$<NOT:$<CONFIG:Debug>>>:-lmsvcrt>
MODULE_NAME
Dispatch
MODULE_LINK_NAME
Expand All @@ -155,11 +153,7 @@ if(ENABLE_SWIFT)
SWIFT_FLAGS
-I ${PROJECT_SOURCE_DIR}
${swift_optimization_flags}
$<$<PLATFORM_ID:Windows>:-Xcc>
$<$<PLATFORM_ID:Windows>:-D_MT>
# TODO(compnerd) handle /MT builds
$<$<PLATFORM_ID:Windows>:-Xcc>
$<$<PLATFORM_ID:Windows>:-D_DLL>
$<$<PLATFORM_ID:Windows>:-libc;${CMAKE_MSVC_RUNTIME_LIBRARY}>
TARGET
${CMAKE_C_COMPILER_TARGET})
endif()
Expand Down