[CMake] Add /winsysroot to lld-link when LLVM_WINSYSROOT is specified
authorArthur Eubanks <aeubanks@google.com>
Thu, 1 Jun 2023 22:46:34 +0000 (15:46 -0700)
committerArthur Eubanks <aeubanks@google.com>
Wed, 5 Jul 2023 16:58:48 +0000 (09:58 -0700)
So that the linker can find libraries in the winsysroot.

Reviewed By: hans, rnk

Differential Revision: https://reviews.llvm.org/D151946

llvm/cmake/modules/HandleLLVMOptions.cmake

index df48742..365c8b9 100644 (file)
@@ -494,6 +494,11 @@ if( MSVC )
       message(ERROR "LLVM_WINSYSROOT requires clang-cl")
     endif()
     append("/winsysroot${LLVM_WINSYSROOT}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+    if (LINKER_IS_LLD_LINK)
+      append("/winsysroot:${LLVM_WINSYSROOT}"
+          CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS
+          CMAKE_SHARED_LINKER_FLAGS)
+    endif()
   endif()
 
   if (LLVM_ENABLE_WERROR)