Skip to content

Commit 1b6722a

Browse files
committed
build: add the default search paths for Windows
When building for Windows on Linux, we need to explicitly setup the linker search paths. These are derivable from the UCRT version and the WinSDK base directories which are expected environment variables. This is also how the swift build system finds the directories. Enable this to avoid having the user explicitly setup the `LIB` environment variable for the linker to find the system import libraries.
1 parent f151b33 commit 1b6722a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
326326
dispatch_windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_MSVC_ARCH)
327327
dispatch_windows_include_for_arch(${DISPATCH_MSVC_ARCH} DISPATCH_INCLUDES)
328328
include_directories(BEFORE SYSTEM ${DISPATCH_INCLUDES})
329+
dispatch_windows_lib_for_arch(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_LIBDIR)
330+
link_directories(${DISPATCH_LIBDIR})
329331
endif()
330332

331333
add_subdirectory(dispatch)

src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ target_link_libraries(dispatch PRIVATE Threads::Threads)
196196
if(WITH_BLOCKS_RUNTIME)
197197
target_link_libraries(dispatch PRIVATE BlocksRuntime)
198198
endif()
199+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
200+
target_link_libraries(dispatch
201+
PRIVATE
202+
WS2_32
203+
WinMM
204+
synchronization)
205+
endif()
199206
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
200207
set_property(TARGET dispatch
201208
APPEND_STRING

0 commit comments

Comments
 (0)