[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang-tools-extra / clangd / CMakeLists.txt
blobde8f087a52a5edc03c552ef4a66716a05dd9779c
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 option(CLANGD_MALLOC_TRIM "Call malloc_trim(3) periodically in Clangd. (only takes effect when using glibc)" ON)
22 # -DCLANG_TIDY_CHECKS=Off avoids a dependency on clang-tidy, reducing rebuilds.
23 option(CLANGD_TIDY_CHECKS "Link all clang-tidy checks into clangd" ON)
25 llvm_canonicalize_cmake_booleans(
26   CLANGD_BUILD_XPC
27   CLANGD_ENABLE_REMOTE
28   ENABLE_GRPC_REFLECTION
29   CLANGD_MALLOC_TRIM
30   CLANGD_TIDY_CHECKS
31   LLVM_ENABLE_ZLIB
34 configure_file(
35   ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
36   ${CMAKE_CURRENT_BINARY_DIR}/Features.inc
39 set(LLVM_LINK_COMPONENTS
40   Support
41   AllTargetsInfos
42   FrontendOpenMP
43   Option
44   )
46 include(${CMAKE_CURRENT_SOURCE_DIR}/quality/CompletionModel.cmake)
47 gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/quality/model CompletionModel clang::clangd::Example)
49 if(MSVC AND NOT CLANG_CL)
50  set_source_files_properties(CompileCommands.cpp PROPERTIES COMPILE_FLAGS -wd4130) # disables C4130: logical operation on address of string constant
51 endif()
53 include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/../clang-tidy")
55 add_clang_library(clangDaemon
56   AST.cpp
57   ASTSignals.cpp
58   ClangdLSPServer.cpp
59   ClangdServer.cpp
60   CodeComplete.cpp
61   CodeCompletionStrings.cpp
62   CollectMacros.cpp
63   CompileCommands.cpp
64   Compiler.cpp
65   Config.cpp
66   ConfigCompile.cpp
67   ConfigProvider.cpp
68   ConfigYAML.cpp
69   Diagnostics.cpp
70   DraftStore.cpp
71   DumpAST.cpp
72   ExpectedTypes.cpp
73   FeatureModule.cpp
74   Feature.cpp
75   FindSymbols.cpp
76   FindTarget.cpp
77   FileDistance.cpp
78   Format.cpp
79   FS.cpp
80   FuzzyMatch.cpp
81   GlobalCompilationDatabase.cpp
82   Headers.cpp
83   HeaderSourceSwitch.cpp
84   HeuristicResolver.cpp
85   Hover.cpp
86   IncludeCleaner.cpp
87   IncludeFixer.cpp
88   InlayHints.cpp
89   JSONTransport.cpp
90   PathMapping.cpp
91   Protocol.cpp
92   Quality.cpp
93   ParsedAST.cpp
94   Preamble.cpp
95   RIFF.cpp
96   Selection.cpp
97   SemanticHighlighting.cpp
98   SemanticSelection.cpp
99   SourceCode.cpp
100   QueryDriverDatabase.cpp
101   TidyProvider.cpp
102   TUScheduler.cpp
103   URI.cpp
104   XRefs.cpp
105   ${CMAKE_CURRENT_BINARY_DIR}/CompletionModel.cpp
107   index/Background.cpp
108   index/BackgroundIndexLoader.cpp
109   index/BackgroundIndexStorage.cpp
110   index/BackgroundQueue.cpp
111   index/BackgroundRebuild.cpp
112   index/CanonicalIncludes.cpp
113   index/FileIndex.cpp
114   index/Index.cpp
115   index/IndexAction.cpp
116   index/MemIndex.cpp
117   index/Merge.cpp
118   index/ProjectAware.cpp
119   index/Ref.cpp
120   index/Relation.cpp
121   index/Serialization.cpp
122   index/StdLib.cpp
123   index/Symbol.cpp
124   index/SymbolCollector.cpp
125   index/SymbolID.cpp
126   index/SymbolLocation.cpp
127   index/SymbolOrigin.cpp
128   index/YAMLSerialization.cpp
130   index/dex/Dex.cpp
131   index/dex/Iterator.cpp
132   index/dex/PostingList.cpp
133   index/dex/Trigram.cpp
135   refactor/InsertionPoint.cpp
136   refactor/Rename.cpp
137   refactor/Tweak.cpp
139   DEPENDS
140   omp_gen
141   )
143 # Include generated CompletionModel headers.
144 target_include_directories(clangDaemon PUBLIC
145   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
148 clang_target_link_libraries(clangDaemon
149   PRIVATE
150   clangAST
151   clangASTMatchers
152   clangBasic
153   clangDriver
154   clangFormat
155   clangFrontend
156   clangIndex
157   clangLex
158   clangSema
159   clangSerialization
160   clangTooling
161   clangToolingCore
162   clangToolingInclusions
163   clangToolingSyntax
164   )
166 target_link_libraries(clangDaemon
167   PRIVATE
168   ${LLVM_PTHREAD_LIB}
170   clangTidy
172   clangdSupport
174   clangPseudo
175   )
176 if(CLANGD_TIDY_CHECKS)
177   target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS})
178 endif()
180 add_subdirectory(refactor/tweaks)
181 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
182   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
183   add_subdirectory(fuzzer)
184 endif()
185 add_subdirectory(tool)
186 add_subdirectory(indexer)
188 if (LLVM_INCLUDE_BENCHMARKS)
189   add_subdirectory(benchmarks)
190 endif()
191 if ( CLANGD_BUILD_XPC )
192   add_subdirectory(xpc)
193 endif ()
195 if (CLANGD_ENABLE_REMOTE)
196   include(FindGRPC)
197 endif()
199 if(CLANG_INCLUDE_TESTS)
200   add_subdirectory(test)
201   add_subdirectory(unittests)
202 endif()
204 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
205 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
206 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
208 add_subdirectory(index/remote)
209 add_subdirectory(index/dex/dexp)