[clang-tools-extra] [cmake] Link against libclang-cpp whenever possible
authorMichal Gorny <mgorny@gentoo.org>
Fri, 4 Oct 2019 20:30:02 +0000 (20:30 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Fri, 4 Oct 2019 20:30:02 +0000 (20:30 +0000)
Use clang_target_link_libraries() in order to support linking against
libclang-cpp instead of static libraries.

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

llvm-svn: 373786

27 files changed:
clang-tools-extra/clang-apply-replacements/tool/CMakeLists.txt
clang-tools-extra/clang-change-namespace/tool/CMakeLists.txt
clang-tools-extra/clang-doc/tool/CMakeLists.txt
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
clang-tools-extra/clang-move/tool/CMakeLists.txt
clang-tools-extra/clang-query/tool/CMakeLists.txt
clang-tools-extra/clang-reorder-fields/tool/CMakeLists.txt
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
clang-tools-extra/clangd/indexer/CMakeLists.txt
clang-tools-extra/clangd/tool/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt
clang-tools-extra/modularize/CMakeLists.txt
clang-tools-extra/pp-trace/CMakeLists.txt
clang-tools-extra/tool-template/CMakeLists.txt
clang-tools-extra/unittests/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/unittests/clang-change-namespace/CMakeLists.txt
clang-tools-extra/unittests/clang-doc/CMakeLists.txt
clang-tools-extra/unittests/clang-include-fixer/CMakeLists.txt
clang-tools-extra/unittests/clang-include-fixer/find-all-symbols/CMakeLists.txt
clang-tools-extra/unittests/clang-move/CMakeLists.txt
clang-tools-extra/unittests/clang-query/CMakeLists.txt
clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

index d15a8b1..1ed734c 100644 (file)
@@ -5,12 +5,15 @@ set(LLVM_LINK_COMPONENTS
 add_clang_tool(clang-apply-replacements
   ClangApplyReplacementsMain.cpp
   )
-target_link_libraries(clang-apply-replacements
+clang_target_link_libraries(clang-apply-replacements
   PRIVATE
-  clangApplyReplacements
   clangBasic
   clangFormat
   clangRewrite
   clangToolingCore
   clangToolingRefactoring
   )
+target_link_libraries(clang-apply-replacements
+  PRIVATE
+  clangApplyReplacements
+  )
index 702bad3..ae48a5e 100644 (file)
@@ -7,12 +7,11 @@ set(LLVM_LINK_COMPONENTS
 add_clang_tool(clang-change-namespace
   ClangChangeNamespace.cpp
   )
-target_link_libraries(clang-change-namespace
+clang_target_link_libraries(clang-change-namespace
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
-  clangChangeNamespace
   clangFormat
   clangFrontend
   clangRewrite
@@ -20,3 +19,7 @@ target_link_libraries(clang-change-namespace
   clangTooling
   clangToolingCore
   )
+target_link_libraries(clang-change-namespace
+  PRIVATE
+  clangChangeNamespace
+  )
index de8c9bc..7e71478 100644 (file)
@@ -4,16 +4,19 @@ add_clang_tool(clang-doc
   ClangDocMain.cpp
   )
 
-target_link_libraries(clang-doc
+clang_target_link_libraries(clang-doc
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
-  clangDoc
   clangTooling
   clangToolingCore
   )
+target_link_libraries(clang-doc
+  PRIVATE
+  clangDoc
+  )
 
 install(FILES ../assets/clang-doc-default-stylesheet.css
   DESTINATION share/clang
index 7f101eb..8f5509d 100644 (file)
@@ -4,7 +4,7 @@ add_clang_tool(find-all-symbols
   FindAllSymbolsMain.cpp
   )
 
-target_link_libraries(find-all-symbols
+clang_target_link_libraries(find-all-symbols
   PRIVATE
   clangAST
   clangASTMatchers
@@ -13,6 +13,9 @@ target_link_libraries(find-all-symbols
   clangLex
   clangSerialization
   clangTooling
+  )
+target_link_libraries(find-all-symbols
+  PRIVATE
   findAllSymbols
   )
 
index 5b600a4..3936ac1 100644 (file)
@@ -4,16 +4,19 @@ add_clang_tool(clang-include-fixer
   ClangIncludeFixer.cpp
   )
 
-target_link_libraries(clang-include-fixer
+clang_target_link_libraries(clang-include-fixer
   PRIVATE
   clangBasic
   clangFormat
   clangFrontend
-  clangIncludeFixer
   clangRewrite
   clangSerialization
   clangTooling
   clangToolingCore
+  )
+target_link_libraries(clang-include-fixer
+  PRIVATE
+  clangIncludeFixer
   findAllSymbols
   )
 
index b6051e4..a0c9c20 100644 (file)
@@ -4,16 +4,19 @@ add_clang_tool(clang-move
   ClangMove.cpp
   )
 
-target_link_libraries(clang-move
+clang_target_link_libraries(clang-move
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangFormat
   clangFrontend
-  clangMove
   clangRewrite
   clangSerialization
   clangTooling
   clangToolingCore
   )
+target_link_libraries(clang-move
+  PRIVATE
+  clangMove
+  )
index 7071c94..be83a7c 100644 (file)
@@ -3,14 +3,17 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 add_clang_tool(clang-query
   ClangQuery.cpp
   )
-target_link_libraries(clang-query
+clang_target_link_libraries(clang-query
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangDynamicASTMatchers
   clangFrontend
-  clangQuery
   clangSerialization
   clangTooling
   )
+target_link_libraries(clang-query
+  PRIVATE
+  clangQuery
+  )
index 718ee96..b414f4f 100644 (file)
@@ -2,13 +2,16 @@ add_clang_tool(clang-reorder-fields
   ClangReorderFields.cpp
   )
 
-target_link_libraries(clang-reorder-fields
+clang_target_link_libraries(clang-reorder-fields
   PRIVATE
   clangBasic
   clangFrontend
-  clangReorderFields
   clangRewrite
   clangSerialization
   clangTooling
   clangToolingCore
   )
+target_link_libraries(clang-reorder-fields
+  PRIVATE
+  clangReorderFields
+  )
index 6dadb27..8e747b3 100644 (file)
@@ -31,7 +31,7 @@ add_clang_library(clangTidy
   )
 
 if(CLANG_ENABLE_STATIC_ANALYZER)
-  target_link_libraries(clangTidy PRIVATE
+  clang_target_link_libraries(clangTidy PRIVATE
     clangStaticAnalyzerCore
     clangStaticAnalyzerFrontend
   )
index fc2b4eb..073749a 100644 (file)
@@ -11,14 +11,17 @@ add_clang_tool(clang-tidy
 add_dependencies(clang-tidy
   clang-resource-headers
   )
-target_link_libraries(clang-tidy
+clang_target_link_libraries(clang-tidy
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
-  clangTidy
   clangTooling
   clangToolingCore
+  )
+target_link_libraries(clang-tidy
+  PRIVATE
+  clangTidy
   ${ALL_CLANG_TIDY_CHECKS}
   )
 
index 28191a3..9037982 100644 (file)
@@ -12,13 +12,16 @@ add_llvm_fuzzer(clangd-fuzzer
   DUMMY_MAIN DummyClangdMain.cpp
   )
 
-target_link_libraries(clangd-fuzzer
+clang_target_link_libraries(clangd-fuzzer
   PRIVATE
   clangBasic
-  clangDaemon
   clangFormat
   clangFrontend
   clangSema
   clangTooling
   clangToolingCore
   )
+target_link_libraries(clangd-fuzzer
+  PRIVATE
+  clangDaemon
+  )
index ece339d..a4edbb3 100644 (file)
@@ -9,8 +9,11 @@ add_clang_executable(dexp
   Dexp.cpp
   )
 
-target_link_libraries(dexp
+clang_target_link_libraries(dexp
   PRIVATE
   clangBasic
+  )
+target_link_libraries(dexp
+  PRIVATE
   clangDaemon
   )
index 92aae06..edbced1 100644 (file)
@@ -8,13 +8,16 @@ add_clang_executable(clangd-indexer
   IndexerMain.cpp
   )
 
-target_link_libraries(clangd-indexer
+clang_target_link_libraries(clangd-indexer
   PRIVATE
   clangAST
   clangBasic
-  clangDaemon
   clangFrontend
   clangIndex
   clangLex
   clangTooling
 )
+target_link_libraries(clangd-indexer
+  PRIVATE
+  clangDaemon
+)
index 085ede3..9ebbe5f 100644 (file)
@@ -15,12 +15,10 @@ if(CLANGD_BUILD_XPC)
   list(APPEND CLANGD_XPC_LIBS "clangdXpcJsonConversions" "clangdXpcTransport")
 endif()
 
-target_link_libraries(clangd
+clang_target_link_libraries(clangd
   PRIVATE
   clangAST
   clangBasic
-  clangTidy
-  clangDaemon
   clangFormat
   clangFrontend
   clangSema
@@ -28,5 +26,10 @@ target_link_libraries(clangd
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
+  )
+target_link_libraries(clangd
+  PRIVATE
+  clangTidy
+  clangDaemon
   ${CLANGD_XPC_LIBS}
   )
index d25745f..7e298b6 100644 (file)
@@ -78,23 +78,26 @@ add_unittest(ClangdUnitTests ClangdTests
   $<TARGET_OBJECTS:obj.clangDaemonTweaks>
   )
 
-target_link_libraries(ClangdTests
+clang_target_link_libraries(ClangdTests
   PRIVATE
   clangAST
   clangBasic
-  clangDaemon
   clangFormat
   clangFrontend
   clangIndex
   clangLex
   clangSema
   clangSerialization
-  clangTidy
   clangTooling
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactoring
   clangToolingSyntax
+  )
+target_link_libraries(ClangdTests
+  PRIVATE
+  clangDaemon
+  clangTidy
   LLVMSupport
   LLVMTestingSupport
   )
index 283599e..1bf01c6 100644 (file)
@@ -13,14 +13,17 @@ set(LLVM_LINK_COMPONENTS
     support
 )
 
-target_link_libraries(clangd-xpc-test-client
+clang_target_link_libraries(clangd-xpc-test-client
   PRIVATE
   clangBasic
-  clangDaemon
   clangFormat
   clangFrontend
   clangSema
   clangTooling
   clangToolingCore
+)
+target_link_libraries(clangd-xpc-test-client
+  PRIVATE
+  clangDaemon
   clangdXpcJsonConversions
 )
index fa2c0e5..4caae81 100644 (file)
@@ -11,7 +11,7 @@ add_clang_tool(modularize
   PreprocessorTracker.cpp
   )
 
-target_link_libraries(modularize
+clang_target_link_libraries(modularize
   PRIVATE
   clangAST
   clangBasic
index 11b45ac..be1d971 100644 (file)
@@ -7,7 +7,7 @@ add_clang_tool(pp-trace
   PPCallbacksTracker.cpp
   )
 
-target_link_libraries(pp-trace
+clang_target_link_libraries(pp-trace
   PRIVATE
   clangAST
   clangBasic
index 9a304d4..959bd3d 100644 (file)
@@ -6,7 +6,7 @@ add_clang_executable(tool-template
   ToolTemplate.cpp
   )
 
-target_link_libraries(tool-template
+clang_target_link_libraries(tool-template
   PRIVATE
   clangAST
   clangASTMatchers
index d3200d7..b345527 100644 (file)
@@ -11,10 +11,13 @@ add_extra_unittest(ClangApplyReplacementsTests
   ApplyReplacementsTest.cpp
   )
 
-target_link_libraries(ClangApplyReplacementsTests
+clang_target_link_libraries(ClangApplyReplacementsTests
   PRIVATE
-  clangApplyReplacements
   clangBasic
   clangToolingCore
   clangToolingRefactoring
   )
+target_link_libraries(ClangApplyReplacementsTests
+  PRIVATE
+  clangApplyReplacements
+  )
index 9c94972..d66f85d 100644 (file)
@@ -15,12 +15,11 @@ add_extra_unittest(ClangChangeNamespaceTests
   ChangeNamespaceTests.cpp
   )
 
-target_link_libraries(ClangChangeNamespaceTests
+clang_target_link_libraries(ClangChangeNamespaceTests
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
-  clangChangeNamespace
   clangFormat
   clangFrontend
   clangRewrite
@@ -28,3 +27,7 @@ target_link_libraries(ClangChangeNamespaceTests
   clangTooling
   clangToolingCore
   )
+target_link_libraries(ClangChangeNamespaceTests
+  PRIVATE
+  clangChangeNamespace
+  )
index 292a1d7..7934cd1 100644 (file)
@@ -20,12 +20,11 @@ add_extra_unittest(ClangDocTests
   YAMLGeneratorTest.cpp
   )
 
-target_link_libraries(ClangDocTests
+clang_target_link_libraries(ClangDocTests
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
-  clangDoc
   clangFormat
   clangFrontend
   clangRewrite
@@ -33,3 +32,7 @@ target_link_libraries(ClangDocTests
   clangTooling
   clangToolingCore
   )
+target_link_libraries(ClangDocTests
+  PRIVATE
+  clangDoc
+  )
index 997aa14..0c0954c 100644 (file)
@@ -16,16 +16,19 @@ add_extra_unittest(ClangIncludeFixerTests
   FuzzySymbolIndexTests.cpp
   )
 
-target_link_libraries(ClangIncludeFixerTests
+clang_target_link_libraries(ClangIncludeFixerTests
   PRIVATE
   clangBasic
   clangFormat
   clangFrontend
-  clangIncludeFixer
   clangRewrite
   clangSerialization
   clangTooling
   clangToolingCore
+  )
+target_link_libraries(ClangIncludeFixerTests
+  PRIVATE
+  clangIncludeFixer
   findAllSymbols
   )
 
index 427aa8e..828d434 100644 (file)
@@ -12,7 +12,7 @@ add_extra_unittest(FindAllSymbolsTests
   FindAllSymbolsTests.cpp
   )
 
-target_link_libraries(FindAllSymbolsTests
+clang_target_link_libraries(FindAllSymbolsTests
   PRIVATE
   clangAST
   clangASTMatchers
@@ -21,5 +21,8 @@ target_link_libraries(FindAllSymbolsTests
   clangLex
   clangSerialization
   clangTooling
+  )
+target_link_libraries(FindAllSymbolsTests
+  PRIVATE
   findAllSymbols
   )
index 1d5347f..468c65c 100644 (file)
@@ -15,16 +15,19 @@ add_extra_unittest(ClangMoveTests
   ClangMoveTests.cpp
   )
 
-target_link_libraries(ClangMoveTests
+clang_target_link_libraries(ClangMoveTests
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangFormat
   clangFrontend
-  clangMove
   clangRewrite
   clangSerialization
   clangTooling
   clangToolingCore
   )
+target_link_libraries(ClangMoveTests
+  PRIVATE
+  clangMove
+  )
index 2177764..9756642 100644 (file)
@@ -11,14 +11,17 @@ add_extra_unittest(ClangQueryTests
   QueryParserTest.cpp
   )
 
-target_link_libraries(ClangQueryTests
+clang_target_link_libraries(ClangQueryTests
   PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangDynamicASTMatchers
   clangFrontend
-  clangQuery
   clangSerialization
   clangTooling
   )
+target_link_libraries(ClangQueryTests
+  PRIVATE
+  clangQuery
+  )
index 93b49f5..287b431 100644 (file)
@@ -21,7 +21,7 @@ add_extra_unittest(ClangTidyTests
   TransformerClangTidyCheckTest.cpp
   )
 
-target_link_libraries(ClangTidyTests
+clang_target_link_libraries(ClangTidyTests
   PRIVATE
   clangAST
   clangASTMatchers
@@ -29,6 +29,12 @@ target_link_libraries(ClangTidyTests
   clangFrontend
   clangLex
   clangSerialization
+  clangTooling
+  clangToolingCore
+  clangToolingRefactoring
+  )
+target_link_libraries(ClangTidyTests
+  PRIVATE
   clangTidy
   clangTidyAndroidModule
   clangTidyGoogleModule
@@ -36,7 +42,4 @@ target_link_libraries(ClangTidyTests
   clangTidyObjCModule
   clangTidyReadabilityModule
   clangTidyUtils
-  clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   )