[clang-tools-extra] Prevent linking to duplicate .a libs and dylib
authorMichał Górny <mgorny@gentoo.org>
Tue, 16 Jun 2020 18:43:55 +0000 (20:43 +0200)
committerMichał Górny <mgorny@gentoo.org>
Wed, 17 Jun 2020 17:00:26 +0000 (19:00 +0200)
Fix various tool libraries not to link to clang's .a libraries and dylib
simultaneously.  This may cause breakage, in particular through
duplicate command-line option declarations.

Differential Revision: https://reviews.llvm.org/D81967

36 files changed:
clang-tools-extra/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/clang-change-namespace/CMakeLists.txt
clang-tools-extra/clang-doc/CMakeLists.txt
clang-tools-extra/clang-include-fixer/CMakeLists.txt
clang-tools-extra/clang-include-fixer/find-all-symbols/CMakeLists.txt
clang-tools-extra/clang-move/CMakeLists.txt
clang-tools-extra/clang-query/CMakeLists.txt
clang-tools-extra/clang-reorder-fields/CMakeLists.txt
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/clang-tidy/android/CMakeLists.txt
clang-tools-extra/clang-tidy/boost/CMakeLists.txt
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
clang-tools-extra/clang-tidy/darwin/CMakeLists.txt
clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/clang-tidy/google/CMakeLists.txt
clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt
clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
clang-tools-extra/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/clang-tidy/mpi/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/clang-tidy/portability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/CMakeLists.txt
clang-tools-extra/clang-tidy/zircon/CMakeLists.txt
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

index 5bfdcb4..27383b4 100644 (file)
@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangApplyReplacements
   lib/Tooling/ApplyReplacements.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangApplyReplacements
+  PRIVATE
   clangAST
   clangBasic
   clangRewrite
index 7c0363c..bfce986 100644 (file)
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangChangeNamespace
   ChangeNamespace.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangChangeNamespace
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
index 8df7d3e..56ec9eb 100644 (file)
@@ -15,8 +15,10 @@ add_clang_library(clangDoc
   Representation.cpp
   Serialize.cpp
   YAMLGenerator.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangDoc
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
index f27f740..d8685cb 100644 (file)
@@ -11,6 +11,11 @@ add_clang_library(clangIncludeFixer
   YamlSymbolIndex.cpp
 
   LINK_LIBS
+  findAllSymbols
+  )
+
+clang_target_link_libraries(clangIncludeFixer
+  PRIVATE
   clangAST
   clangBasic
   clangFormat
@@ -21,7 +26,6 @@ add_clang_library(clangIncludeFixer
   clangSerialization
   clangTooling
   clangToolingCore
-  findAllSymbols
   )
 
 add_subdirectory(plugin)
index 20afecd..c0760e8 100644 (file)
@@ -12,8 +12,10 @@ add_clang_library(findAllSymbols
   PragmaCommentHandler.cpp
   STLPostfixHeaderMap.cpp
   SymbolInfo.cpp
+  )
 
-  LINK_LIBS
+clang_target_link_libraries(findAllSymbols
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
index 4bd8bbb..e3bef84 100644 (file)
@@ -6,8 +6,10 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangMove
   Move.cpp
   HelperDeclRefGraph.cpp
+  )
 
-  LINK_LIBS
+clang_target_link_libraries(clangMove
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
index 78d73ec..8192ec4 100644 (file)
@@ -7,8 +7,10 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangQuery
   Query.cpp
   QueryParser.cpp
+  )
 
-  LINK_LIBS
+clang_target_link_libraries(clangQuery
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
index c357d0a..995efbb 100644 (file)
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangReorderFields
   ReorderFieldsAction.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangReorderFields
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
index 1644ca8..f552cb3 100644 (file)
@@ -15,8 +15,10 @@ add_clang_library(clangTidy
 
   DEPENDS
   ClangSACheckers
+  )
 
-  LINK_LIBS
+clang_target_link_libraries(clangTidy
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
@@ -32,7 +34,8 @@ add_clang_library(clangTidy
   )
 
 if(CLANG_ENABLE_STATIC_ANALYZER)
-  target_link_libraries(clangTidy PRIVATE
+  clang_target_link_libraries(clangTidy
+    PRIVATE
     clangStaticAnalyzerCore
     clangStaticAnalyzerFrontend
   )
index 5926717..7d8601a 100644 (file)
@@ -26,12 +26,16 @@ add_clang_library(clangTidyAbseilModule
   UpgradeDurationConversionsCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyAbseilModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   clangTooling
   clangTransformer
   )
index 0b10702..72ed160 100644 (file)
@@ -23,10 +23,14 @@ add_clang_library(clangTidyAndroidModule
   ComparisonInTempFailureRetryCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyAndroidModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index 4d2cb6f..2bddb70 100644 (file)
@@ -8,10 +8,14 @@ add_clang_library(clangTidyBoostModule
   UseToStringCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyBoostModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index 4f13847..e220fd0 100644 (file)
@@ -59,13 +59,17 @@ add_clang_library(clangTidyBugproneModule
   VirtualNearMissCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyCppCoreGuidelinesModule
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyBugproneModule
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyCppCoreGuidelinesModule
-  clangTidyUtils
   clangTooling
   )
index f6664c9..2aa1727 100644 (file)
@@ -21,10 +21,6 @@ add_clang_library(clangTidyCERTModule
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS
-  clangAST
-  clangASTMatchers
-  clangBasic
-  clangLex
   clangTidy
   clangTidyBugproneModule
   clangTidyGoogleModule
@@ -33,3 +29,11 @@ add_clang_library(clangTidyCERTModule
   clangTidyReadabilityModule
   clangTidyUtils
   )
+
+clang_target_link_libraries(clangTidyCERTModule
+  PRIVATE
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  )
index bfc19fe..797799d 100644 (file)
@@ -27,15 +27,19 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
   SpecialMemberFunctionsCheck.cpp
 
   LINK_LIBS
-  clangAST
-  clangASTMatchers
-  clangBasic
-  clangLex
-  clangSerialization
   clangTidy
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyReadabilityModule
   clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyCppCoreGuidelinesModule
+  PRIVATE
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangSerialization
   clangTooling
   )
index 2af86b2..28245b7 100644 (file)
@@ -9,11 +9,15 @@ add_clang_library(clangTidyDarwinModule
   DispatchOnceNonstaticCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyDarwinModule
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index c8e39dd..daf092e 100644 (file)
@@ -14,11 +14,15 @@ add_clang_library(clangTidyFuchsiaModule
   VirtualInheritanceCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyGoogleModule
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyFuchsiaModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyGoogleModule
-  clangTidyUtils
   )
index ab0fbb5..68076c1 100644 (file)
@@ -24,11 +24,15 @@ add_clang_library(clangTidyGoogleModule
   UsingNamespaceDirectiveCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyReadabilityModule
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyGoogleModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyReadabilityModule
-  clangTidyUtils
   )
index 827e6bd..53edd21 100644 (file)
@@ -11,11 +11,6 @@ add_clang_library(clangTidyHICPPModule
   SignedBitwiseCheck.cpp
 
   LINK_LIBS
-  clangAST
-  clangASTMatchers
-  clangBasic
-  clangLex
-  clangSerialization
   clangTidy
   clangTidyBugproneModule
   clangTidyCppCoreGuidelinesModule
@@ -26,3 +21,12 @@ add_clang_library(clangTidyHICPPModule
   clangTidyReadabilityModule
   clangTidyUtils
   )
+
+clang_target_link_libraries(clangTidyHICPPModule
+  PRIVATE
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangSerialization
+  )
index 39b499b..5edb652 100644 (file)
@@ -8,10 +8,14 @@ add_clang_library(clangTidyLinuxKernelModule
   MustCheckErrsCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyLinuxKernelModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index e68bb69..74c92ee 100644 (file)
@@ -12,12 +12,16 @@ add_clang_library(clangTidyLLVMModule
   TwineLocalCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyReadabilityModule
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyLLVMModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyReadabilityModule
-  clangTidyUtils
   clangTooling
   )
index 9d4edb2..4a4e654 100644 (file)
@@ -10,12 +10,16 @@ add_clang_library(clangTidyLLVMLibcModule
   RestrictSystemLibcHeadersCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyPortabilityModule
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyLLVMLibcModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyPortabilityModule
-  clangTidyUtils
   clangTooling
   )
index 80796fc..236a3a8 100644 (file)
@@ -21,13 +21,17 @@ add_clang_library(clangTidyMiscModule
   UnusedUsingDeclsCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyMiscModule
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
   clangSerialization
-  clangTidy
-  clangTidyUtils
   clangTooling
   )
index c74c405..ee17027 100644 (file)
@@ -40,12 +40,16 @@ add_clang_library(clangTidyModernizeModule
   UseUsingCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyReadabilityModule
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyModernizeModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyReadabilityModule
-  clangTidyUtils
   clangTooling
   )
index c4dc6bf..1ac9736 100644 (file)
@@ -9,13 +9,17 @@ add_clang_library(clangTidyMPIModule
   TypeMismatchCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyMPIModule
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   clangTooling
   clangStaticAnalyzerCheckers
   )
index 5c6c505..297471b 100644 (file)
@@ -14,10 +14,14 @@ add_clang_library(clangTidyObjCModule
   SuperSelfCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyObjCModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index 78f1e91..a23c719 100644 (file)
@@ -9,9 +9,13 @@ add_clang_library(clangTidyOpenMPModule
   UseDefaultNoneCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyOpenMPModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
-  clangTidy
-  clangTidyUtils
   )
index 83638b4..5aa8c24 100644 (file)
@@ -21,11 +21,15 @@ add_clang_library(clangTidyPerformanceModule
   UnnecessaryValueParamCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyPerformanceModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangAnalysis
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index 4adc3f2..0bfe122 100644 (file)
@@ -2,12 +2,16 @@ add_clang_library(clangTidyPlugin
   ClangTidyPlugin.cpp
 
   LINK_LIBS
+  clangTidy
+  ${ALL_CLANG_TIDY_CHECKS}
+  )
+
+clang_target_link_libraries(clangTidyPlugin
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangSema
-  clangTidy
   clangTooling
-  ${ALL_CLANG_TIDY_CHECKS}
   )
index d3b05d3..b4fcf28 100644 (file)
@@ -9,11 +9,15 @@ add_clang_library(clangTidyPortabilityModule
   SIMDIntrinsicsCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyPortabilityModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   clangTooling
   )
index 02003a7..ca2f69b 100644 (file)
@@ -45,12 +45,16 @@ add_clang_library(clangTidyReadabilityModule
   UseAnyOfAllOfCheck.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyReadabilityModule
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   clangTooling
   )
index ff9104b..00554e4 100644 (file)
@@ -13,11 +13,15 @@ add_clang_library(clangTidyMain
   ClangTidyMain.cpp
 
   LINK_LIBS
+  clangTidy
+  ${ALL_CLANG_TIDY_CHECKS}
+  )
+
+clang_target_link_libraries(clangTidyMain
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
-  clangTidy
-  ${ALL_CLANG_TIDY_CHECKS}
   clangTooling
   clangToolingCore
   )
index 2f5ecc4..26032f2 100644 (file)
@@ -22,11 +22,15 @@ add_clang_library(clangTidyUtils
   UsingInserter.cpp
 
   LINK_LIBS
+  clangTidy
+  )
+
+clang_target_link_libraries(clangTidyUtils
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
   clangSema
-  clangTidy
   clangTransformer
   )
index 04db242..29c99e9 100644 (file)
@@ -8,10 +8,14 @@ add_clang_library(clangTidyZirconModule
   ZirconTidyModule.cpp
 
   LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyZirconModule
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangLex
-  clangTidy
-  clangTidyUtils
   )
index dd3e027..fa4f8b4 100644 (file)
@@ -96,6 +96,14 @@ add_clang_library(clangDaemon
   refactor/Tweak.cpp
 
   LINK_LIBS
+  clangdSupport
+  clangTidy
+  ${LLVM_PTHREAD_LIB}
+  ${ALL_CLANG_TIDY_CHECKS}
+  )
+
+clang_target_link_libraries(clangDaemon
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
@@ -106,15 +114,11 @@ add_clang_library(clangDaemon
   clangLex
   clangSema
   clangSerialization
-  clangTidy
   clangTooling
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactoring
   clangToolingSyntax
-  clangdSupport
-  ${LLVM_PTHREAD_LIB}
-  ${ALL_CLANG_TIDY_CHECKS}
   )
 
 add_subdirectory(refactor/tweaks)
index b907dfe..03e0966 100644 (file)
@@ -120,7 +120,6 @@ target_link_libraries(ClangdTests
   clangDaemon
   clangdSupport
   clangTidy
-  LLVMSupport
   LLVMTestingSupport
   )