[CMake][Win32.DLL] Let llvm_add_library(SHARED) link dependent libraries as PRIVATE.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 14 Jul 2014 12:26:15 +0000 (12:26 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 14 Jul 2014 12:26:15 +0000 (12:26 +0000)
For example, c-index-test.exe requires just libclang.dll (its import library).
When libraries in libclang were not PRIVATE but PUBLIC, c-index-test required libraries transitive by libclang.

Note, on mingw with BUILD_SHARED_LIBS, library dependencies would become more strict.
In principle, required libraries should be "required in its source file".

This will help to detect missing dependencies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212934 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/AddLLVM.cmake

index 85149abf5e3ef971b89daf0942086819a2a55636..0276bf6ffe406b638099f41f76ed808b0e1eadad 100644 (file)
@@ -333,6 +333,13 @@ function(llvm_add_library name)
       ${lib_deps}
       ${llvm_libs}
       )
+  elseif((CYGWIN OR WIN32) AND ARG_SHARED)
+    # Win32's import library may be unaware of its dependent libs.
+    target_link_libraries(${name} PRIVATE
+      ${ARG_LINK_LIBS}
+      ${lib_deps}
+      ${llvm_libs}
+      )
   elseif(ARG_SHARED AND BUILD_SHARED_LIBS)
     # FIXME: It may be PRIVATE since SO knows its dependent libs.
     target_link_libraries(${name} PUBLIC