From bc66ff2789582b596fa02725c616373ed55a7b26 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 23 Aug 2024 11:41:15 -0700 Subject: [PATCH] [Build] add kernel_link_options for windows (#4865) Add msvc version of kernel_link_options. For #4661 --- build/Utils.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build/Utils.cmake b/build/Utils.cmake index 56fc1e104b..55f5892a55 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -143,11 +143,21 @@ function(macos_kernel_link_options target_name) ) endfunction() +# Same as kernel_link_options but it's for MSVC linker +function(msvc_kernel_link_options target_name) + target_link_options( + ${target_name} INTERFACE + "SHELL:LINKER:/WHOLEARCHIVE:$" + ) +endfunction() + # Ensure that the load-time constructor functions run. By default, the linker # would remove them since there are no other references to them. function(target_link_options_shared_lib target_name) if(APPLE) macos_kernel_link_options(${target_name}) + elseif(MSVC) + msvc_kernel_link_options(${target_name}) else() kernel_link_options(${target_name}) endif()