[clang-tools-extra] Prevent linking to duplicate .a libs and dylib
[lldb.git] / clang-tools-extra / clangd / CMakeLists.txt
1 add_subdirectory(support)
2
3 # Configure the Features.inc file.
4 if (NOT DEFINED CLANGD_BUILD_XPC)
5   if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
6     set(CLANGD_BUILD_XPC_DEFAULT ON)
7   else ()
8     set(CLANGD_BUILD_XPC_DEFAULT OFF)
9   endif ()
10
11   llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC_DEFAULT)
12
13   set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE)
14   unset(CLANGD_BUILD_XPC_DEFAULT)
15 endif ()
16
17 llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC)
18
19 configure_file(
20   ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
21   ${CMAKE_CURRENT_BINARY_DIR}/Features.inc
22 )
23
24 set(LLVM_LINK_COMPONENTS
25   Support
26   AllTargetsInfos
27   FrontendOpenMP
28   )
29
30 add_clang_library(clangDaemon
31   AST.cpp
32   ClangdLSPServer.cpp
33   ClangdServer.cpp
34   CodeComplete.cpp
35   CodeCompletionStrings.cpp
36   CollectMacros.cpp
37   CompileCommands.cpp
38   Compiler.cpp
39   Diagnostics.cpp
40   DraftStore.cpp
41   ExpectedTypes.cpp
42   FindSymbols.cpp
43   FindTarget.cpp
44   FileDistance.cpp
45   Format.cpp
46   FS.cpp
47   FuzzyMatch.cpp
48   GlobalCompilationDatabase.cpp
49   Headers.cpp
50   HeaderSourceSwitch.cpp
51   Hover.cpp
52   IncludeFixer.cpp
53   JSONTransport.cpp
54   PathMapping.cpp
55   Protocol.cpp
56   Quality.cpp
57   ParsedAST.cpp
58   Preamble.cpp
59   RIFF.cpp
60   Selection.cpp
61   SemanticHighlighting.cpp
62   SemanticSelection.cpp
63   SourceCode.cpp
64   QueryDriverDatabase.cpp
65   TUScheduler.cpp
66   URI.cpp
67   XRefs.cpp
68
69   index/Background.cpp
70   index/BackgroundIndexLoader.cpp
71   index/BackgroundIndexStorage.cpp
72   index/BackgroundQueue.cpp
73   index/BackgroundRebuild.cpp
74   index/CanonicalIncludes.cpp
75   index/FileIndex.cpp
76   index/Index.cpp
77   index/IndexAction.cpp
78   index/MemIndex.cpp
79   index/Merge.cpp
80   index/Ref.cpp
81   index/Relation.cpp
82   index/Serialization.cpp
83   index/Symbol.cpp
84   index/SymbolCollector.cpp
85   index/SymbolID.cpp
86   index/SymbolLocation.cpp
87   index/SymbolOrigin.cpp
88   index/YAMLSerialization.cpp
89
90   index/dex/Dex.cpp
91   index/dex/Iterator.cpp
92   index/dex/PostingList.cpp
93   index/dex/Trigram.cpp
94
95   refactor/Rename.cpp
96   refactor/Tweak.cpp
97
98   LINK_LIBS
99   clangdSupport
100   clangTidy
101   ${LLVM_PTHREAD_LIB}
102   ${ALL_CLANG_TIDY_CHECKS}
103   )
104
105 clang_target_link_libraries(clangDaemon
106   PRIVATE
107   clangAST
108   clangASTMatchers
109   clangBasic
110   clangDriver
111   clangFormat
112   clangFrontend
113   clangIndex
114   clangLex
115   clangSema
116   clangSerialization
117   clangTooling
118   clangToolingCore
119   clangToolingInclusions
120   clangToolingRefactoring
121   clangToolingSyntax
122   )
123
124 add_subdirectory(refactor/tweaks)
125 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
126   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
127   add_subdirectory(fuzzer)
128 endif()
129 add_subdirectory(tool)
130 add_subdirectory(indexer)
131
132 if (LLVM_INCLUDE_BENCHMARKS)
133   add_subdirectory(benchmarks)
134 endif()
135 if ( CLANGD_BUILD_XPC )
136   add_subdirectory(xpc)
137 endif ()
138
139 if(CLANG_INCLUDE_TESTS)
140 add_subdirectory(test)
141 add_subdirectory(unittests)
142 endif()
143
144 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
145 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
146 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
147
148 if (CLANGD_ENABLE_REMOTE)
149   include(FindGRPC)
150 endif()
151 add_subdirectory(index/remote)
152 add_subdirectory(index/dex/dexp)