From 1b6722affa6ba4b3ee66ecc88d58990f8389a4bb Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 29 Mar 2018 14:11:27 -0700 Subject: [PATCH] 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. --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0adcb598..a9a6e5072 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,6 +326,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows) dispatch_windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_MSVC_ARCH) dispatch_windows_include_for_arch(${DISPATCH_MSVC_ARCH} DISPATCH_INCLUDES) include_directories(BEFORE SYSTEM ${DISPATCH_INCLUDES}) + dispatch_windows_lib_for_arch(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_LIBDIR) + link_directories(${DISPATCH_LIBDIR}) endif() add_subdirectory(dispatch) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7cd89bbd..3471fd0a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -196,6 +196,13 @@ target_link_libraries(dispatch PRIVATE Threads::Threads) if(WITH_BLOCKS_RUNTIME) target_link_libraries(dispatch PRIVATE BlocksRuntime) endif() +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + target_link_libraries(dispatch + PRIVATE + WS2_32 + WinMM + synchronization) +endif() if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set_property(TARGET dispatch APPEND_STRING