[PATCH] D78534: [libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 14:02:26 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8990feb125a: [libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON (authored by zhuhan0, committed by smeenai).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78534/new/

https://reviews.llvm.org/D78534

Files:
  clang/cmake/modules/AddClang.cmake


Index: clang/cmake/modules/AddClang.cmake
===================================================================
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -99,38 +99,40 @@
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
-  if(TARGET ${name})
-    target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
-
-    if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
-      set(export_to_clangtargets)
-      if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-          "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-          NOT LLVM_DISTRIBUTION_COMPONENTS)
-        set(export_to_clangtargets EXPORT ClangTargets)
-        set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
+  foreach(lib ${name} ${name}_static)
+    if(TARGET ${lib})
+      target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
+
+      if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
+        set(export_to_clangtargets)
+        if(${lib} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+            "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+            NOT LLVM_DISTRIBUTION_COMPONENTS)
+          set(export_to_clangtargets EXPORT ClangTargets)
+          set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
+        endif()
+
+        install(TARGETS ${lib}
+          COMPONENT ${lib}
+          ${export_to_clangtargets}
+          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+          RUNTIME DESTINATION bin)
+
+        if (NOT LLVM_ENABLE_IDE)
+          add_llvm_install_targets(install-${lib}
+                                   DEPENDS ${lib}
+                                   COMPONENT ${lib})
+        endif()
+
+        set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${lib})
       endif()
-
-      install(TARGETS ${name}
-        COMPONENT ${name}
-        ${export_to_clangtargets}
-        LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-        ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-        RUNTIME DESTINATION bin)
-
-      if (NOT LLVM_ENABLE_IDE)
-        add_llvm_install_targets(install-${name}
-                                 DEPENDS ${name}
-                                 COMPONENT ${name})
-      endif()
-
-      set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
+      set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${lib})
+    else()
+      # Add empty "phony" target
+      add_custom_target(${lib})
     endif()
-    set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
-  else()
-    # Add empty "phony" target
-    add_custom_target(${name})
-  endif()
+  endforeach()
 
   set_target_properties(${name} PROPERTIES FOLDER "Clang libraries")
   set_clang_windows_version_resource_properties(${name})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78534.260453.patch
Type: text/x-patch
Size: 2835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200427/3a7695e1/attachment-0001.bin>


More information about the cfe-commits mailing list