Skip to content

Commit d30945d

Browse files
compnerdktopley-apple
authored andcommitted
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. Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
1 parent 45fa335 commit d30945d

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
@@ -328,6 +328,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
328328
dispatch_windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_MSVC_ARCH)
329329
dispatch_windows_include_for_arch(${DISPATCH_MSVC_ARCH} DISPATCH_INCLUDES)
330330
include_directories(BEFORE SYSTEM ${DISPATCH_INCLUDES})
331+
dispatch_windows_lib_for_arch(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_LIBDIR)
332+
link_directories(${DISPATCH_LIBDIR})
331333
endif()
332334

333335
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)