[PATCH] D67321: Respect CLANG_LINK_CLANG_DYLIB=ON in libclang and c-index-test

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 7 10:11:14 PDT 2019


aaronpuchert created this revision.
aaronpuchert added reviewers: akyrtzi, beanz, tstellar.
Herald added subscribers: cfe-commits, arphaman, dexonsmith, mgorny.
Herald added a project: clang.
aaronpuchert added inline comments.


================
Comment at: clang/tools/libclang/CMakeLists.txt:115
+clang_target_link_libraries(libclang
+  PRIVATE
+  ${CLANG_LIB_DEPS}
----------------
This might not be correct for static builds, I think we need `INTERFACE` here.


Without these changes an application can't link both libclang and
clang-shlib ("clang-cpp") at the same time, because otherwise some flags
are registered twice. This was observable in c-index-test with the flag
"-limited-coverage-experimental" from lib/CodeGen/CodeGenModule.cpp.

This also further reduces the installation size of Clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67321

Files:
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===================================================================
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -33,7 +33,7 @@
   ../../include/clang-c/Index.h
   )
 
-set(LIBS
+set(CLANG_LIB_DEPS
   clangAST
   clangBasic
   clangDriver
@@ -46,7 +46,7 @@
 )
 
 if (CLANG_ENABLE_ARCMT)
-  list(APPEND LIBS clangARCMigrate)
+  list(APPEND CLANG_LIB_DEPS clangARCMigrate)
 endif ()
 
 if (TARGET clangTidyPlugin)
@@ -111,6 +111,11 @@
   Support
   )
 
+clang_target_link_libraries(libclang
+  PRIVATE
+  ${CLANG_LIB_DEPS}
+  )
+
 if(ENABLE_SHARED)
   if(WIN32)
     set_target_properties(libclang
Index: clang/tools/c-index-test/CMakeLists.txt
===================================================================
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -25,6 +25,9 @@
   target_link_libraries(c-index-test
     PRIVATE
     libclang
+  )
+  clang_target_link_libraries(c-index-test
+    PRIVATE
     clangAST
     clangBasic
     clangCodeGen


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67321.219248.patch
Type: text/x-patch
Size: 1073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190907/0b2932eb/attachment.bin>


More information about the cfe-commits mailing list