Add whole_archive_link support for MSVC.
authorRiver Riddle <riverriddle@google.com>
Wed, 29 May 2019 20:47:24 +0000 (13:47 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 03:08:32 +0000 (20:08 -0700)
    This issue was discovered by @loic-joly-sonarsource with a proposed fix
    in https://github.com/tensorflow/mlir/pull/22.

--

PiperOrigin-RevId: 250558504

mlir/CMakeLists.txt

index 473191d..4e1b3e5 100644 (file)
@@ -25,6 +25,10 @@ function(whole_archive_link target)
     FOREACH(LIB ${ARGN})
       string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
     ENDFOREACH(LIB)
+  elseif(MSVC)
+    FOREACH(LIB ${ARGN})
+      string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${LIB} ")
+    ENDFOREACH(LIB)
   else()
     set(link_flags "-L${CMAKE_BINARY_DIR}/lib -Wl,--whole-archive,")
     FOREACH(LIB ${ARGN})