Bump version to 19.1.0git
[llvm-project.git] / clang-tools-extra / clangd / CMakeLists.txt
blobc21d277d2ffcbd83cae8f1aaad1dc410431a2752
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   ModulesBuilder.cpp
101   PathMapping.cpp
102   Protocol.cpp
103   Quality.cpp
104   ParsedAST.cpp
105   Preamble.cpp
106   RIFF.cpp
107   ScanningProjectModules.cpp
108   Selection.cpp
109   SemanticHighlighting.cpp
110   SemanticSelection.cpp
111   SourceCode.cpp
112   SystemIncludeExtractor.cpp
113   TidyProvider.cpp
114   TUScheduler.cpp
115   URI.cpp
116   XRefs.cpp
117   ${COMPLETIONMODEL_SOURCES}
119   index/Background.cpp
120   index/BackgroundIndexLoader.cpp
121   index/BackgroundIndexStorage.cpp
122   index/BackgroundQueue.cpp
123   index/BackgroundRebuild.cpp
124   index/CanonicalIncludes.cpp
125   index/FileIndex.cpp
126   index/Index.cpp
127   index/IndexAction.cpp
128   index/MemIndex.cpp
129   index/Merge.cpp
130   index/ProjectAware.cpp
131   index/Ref.cpp
132   index/Relation.cpp
133   index/Serialization.cpp
134   index/StdLib.cpp
135   index/Symbol.cpp
136   index/SymbolCollector.cpp
137   index/SymbolID.cpp
138   index/SymbolLocation.cpp
139   index/SymbolOrigin.cpp
140   index/YAMLSerialization.cpp
142   index/dex/Dex.cpp
143   index/dex/Iterator.cpp
144   index/dex/PostingList.cpp
145   index/dex/Trigram.cpp
147   refactor/InsertionPoint.cpp
148   refactor/Rename.cpp
149   refactor/Tweak.cpp
151   DEPENDS
152   omp_gen
153   ClangDriverOptions
154   )
156 # Include generated CompletionModel headers.
157 target_include_directories(clangDaemon PUBLIC
158   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
161 clang_target_link_libraries(clangDaemon
162   PRIVATE
163   clangAST
164   clangASTMatchers
165   clangBasic
166   clangDependencyScanning
167   clangDriver
168   clangFormat
169   clangFrontend
170   clangIndex
171   clangLex
172   clangSema
173   clangSerialization
174   clangTooling
175   clangToolingCore
176   clangToolingInclusions
177   clangToolingInclusionsStdlib
178   clangToolingSyntax
179   )
181 target_link_libraries(clangDaemon
182   PRIVATE
183   ${LLVM_PTHREAD_LIB}
185   clangIncludeCleaner
186   clangPseudo
187   clangTidy
188   clangTidyUtils
190   clangdSupport
191   )
192 if(CLANGD_TIDY_CHECKS)
193   target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS})
194 endif()
196 add_subdirectory(refactor/tweaks)
197 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
198   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
199   add_subdirectory(fuzzer)
200 endif()
201 add_subdirectory(tool)
202 add_subdirectory(indexer)
204 if (LLVM_INCLUDE_BENCHMARKS)
205   add_subdirectory(benchmarks)
206 endif()
207 if ( CLANGD_BUILD_XPC )
208   add_subdirectory(xpc)
209 endif ()
211 if (CLANGD_ENABLE_REMOTE)
212   include(AddGRPC)
213 endif()
215 if(CLANG_INCLUDE_TESTS)
216   add_subdirectory(test)
217   add_subdirectory(unittests)
218 endif()
220 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
221 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
222 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
224 add_subdirectory(index/remote)
225 add_subdirectory(index/dex/dexp)