[mlir][sparse] implement non-permutation MapRef encoding (#69406)
[llvm-project.git] / clang-tools-extra / clangd / CMakeLists.txt
blob3911fb6c6c746a8f8ade8677332ca1f399bfc3f9
1 # This is a no-op for building files in this dir, but is inherited by subdirs.
2 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
3 include_directories(${CMAKE_CURRENT_BINARY_DIR})
5 add_subdirectory(support)
7 # Configure the Features.inc file.
8 if (NOT DEFINED CLANGD_BUILD_XPC)
9   if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
10     set(CLANGD_BUILD_XPC_DEFAULT ON)
11   else ()
12     set(CLANGD_BUILD_XPC_DEFAULT OFF)
13   endif ()
15   llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC_DEFAULT)
17   set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE)
18   unset(CLANGD_BUILD_XPC_DEFAULT)
19 endif ()
21 # This involves generating and compiling large source files, which can run into toolchain limitations.
22 option(CLANGD_DECISION_FOREST "Enable decision forest model for ranking code completion items" ON)
23 option(CLANGD_MALLOC_TRIM "Call malloc_trim(3) periodically in Clangd. (only takes effect when using glibc)" ON)
24 # -DCLANG_TIDY_CHECKS=Off avoids a dependency on clang-tidy, reducing rebuilds.
25 option(CLANGD_TIDY_CHECKS "Link all clang-tidy checks into clangd" ON)
27 llvm_canonicalize_cmake_booleans(
28   CLANGD_BUILD_XPC
29   CLANGD_ENABLE_REMOTE
30   ENABLE_GRPC_REFLECTION
31   CLANGD_MALLOC_TRIM
32   CLANGD_TIDY_CHECKS
33   LLVM_ENABLE_ZLIB
34   CLANGD_DECISION_FOREST
37 configure_file(
38   ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
39   ${CMAKE_CURRENT_BINARY_DIR}/Features.inc
42 set(LLVM_LINK_COMPONENTS
43   Support
44   AllTargetsInfos
45   FrontendOpenMP
46   Option
47   TargetParser
48   )
50 set(COMPLETIONMODEL_SOURCES)
51 if(CLANGD_DECISION_FOREST)
52   include(${CMAKE_CURRENT_SOURCE_DIR}/quality/CompletionModel.cmake)
53   gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/quality/model CompletionModel clang::clangd::Example)
54   list(APPEND COMPLETIONMODEL_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/CompletionModel.cpp)
55 endif()
57 if(MSVC AND NOT CLANG_CL)
58  set_source_files_properties(CompileCommands.cpp PROPERTIES COMPILE_FLAGS -wd4130) # disables C4130: logical operation on address of string constant
59 endif()
61 include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/../clang-tidy")
62 include_directories(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../include-cleaner/include")
64 add_clang_library(clangDaemon
65   AST.cpp
66   ASTSignals.cpp
67   ClangdLSPServer.cpp
68   ClangdServer.cpp
69   CodeComplete.cpp
70   CodeCompletionStrings.cpp
71   CollectMacros.cpp
72   CompileCommands.cpp
73   Compiler.cpp
74   Config.cpp
75   ConfigCompile.cpp
76   ConfigProvider.cpp
77   ConfigYAML.cpp
78   DecisionForest.cpp
79   Diagnostics.cpp
80   DraftStore.cpp
81   DumpAST.cpp
82   ExpectedTypes.cpp
83   FeatureModule.cpp
84   Feature.cpp
85   FindSymbols.cpp
86   FindTarget.cpp
87   FileDistance.cpp
88   Format.cpp
89   FS.cpp
90   FuzzyMatch.cpp
91   GlobalCompilationDatabase.cpp
92   Headers.cpp
93   HeaderSourceSwitch.cpp
94   HeuristicResolver.cpp
95   Hover.cpp
96   IncludeCleaner.cpp
97   IncludeFixer.cpp
98   InlayHints.cpp
99   JSONTransport.cpp
100   PathMapping.cpp
101   Protocol.cpp
102   Quality.cpp
103   ParsedAST.cpp
104   Preamble.cpp
105   RIFF.cpp
106   Selection.cpp
107   SemanticHighlighting.cpp
108   SemanticSelection.cpp
109   SourceCode.cpp
110   SystemIncludeExtractor.cpp
111   TidyProvider.cpp
112   TUScheduler.cpp
113   URI.cpp
114   XRefs.cpp
115   ${COMPLETIONMODEL_SOURCES}
117   index/Background.cpp
118   index/BackgroundIndexLoader.cpp
119   index/BackgroundIndexStorage.cpp
120   index/BackgroundQueue.cpp
121   index/BackgroundRebuild.cpp
122   index/CanonicalIncludes.cpp
123   index/FileIndex.cpp
124   index/Index.cpp
125   index/IndexAction.cpp
126   index/MemIndex.cpp
127   index/Merge.cpp
128   index/ProjectAware.cpp
129   index/Ref.cpp
130   index/Relation.cpp
131   index/Serialization.cpp
132   index/StdLib.cpp
133   index/Symbol.cpp
134   index/SymbolCollector.cpp
135   index/SymbolID.cpp
136   index/SymbolLocation.cpp
137   index/SymbolOrigin.cpp
138   index/YAMLSerialization.cpp
140   index/dex/Dex.cpp
141   index/dex/Iterator.cpp
142   index/dex/PostingList.cpp
143   index/dex/Trigram.cpp
145   refactor/InsertionPoint.cpp
146   refactor/Rename.cpp
147   refactor/Tweak.cpp
149   DEPENDS
150   omp_gen
151   ClangDriverOptions
152   )
154 # Include generated CompletionModel headers.
155 target_include_directories(clangDaemon PUBLIC
156   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
159 clang_target_link_libraries(clangDaemon
160   PRIVATE
161   clangAST
162   clangASTMatchers
163   clangBasic
164   clangDriver
165   clangFormat
166   clangFrontend
167   clangIndex
168   clangLex
169   clangSema
170   clangSerialization
171   clangTooling
172   clangToolingCore
173   clangToolingInclusions
174   clangToolingInclusionsStdlib
175   clangToolingSyntax
176   )
178 target_link_libraries(clangDaemon
179   PRIVATE
180   ${LLVM_PTHREAD_LIB}
182   clangIncludeCleaner
183   clangPseudo
184   clangTidy
186   clangdSupport
187   )
188 if(CLANGD_TIDY_CHECKS)
189   target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS})
190 endif()
192 add_subdirectory(refactor/tweaks)
193 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
194   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
195   add_subdirectory(fuzzer)
196 endif()
197 add_subdirectory(tool)
198 add_subdirectory(indexer)
200 if (LLVM_INCLUDE_BENCHMARKS)
201   add_subdirectory(benchmarks)
202 endif()
203 if ( CLANGD_BUILD_XPC )
204   add_subdirectory(xpc)
205 endif ()
207 if (CLANGD_ENABLE_REMOTE)
208   include(AddGRPC)
209 endif()
211 if(CLANG_INCLUDE_TESTS)
212   add_subdirectory(test)
213   add_subdirectory(unittests)
214 endif()
216 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
217 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
218 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
220 add_subdirectory(index/remote)
221 add_subdirectory(index/dex/dexp)