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)
12 set(CLANGD_BUILD_XPC_DEFAULT OFF)
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)
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(
30 ENABLE_GRPC_REFLECTION
34 CLANGD_DECISION_FOREST
38 ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
39 ${CMAKE_CURRENT_BINARY_DIR}/Features.inc
42 set(LLVM_LINK_COMPONENTS
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)
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
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 STATIC
70 CodeCompletionStrings.cpp
91 GlobalCompilationDatabase.cpp
93 HeaderSourceSwitch.cpp
107 ScanningProjectModules.cpp
109 SemanticHighlighting.cpp
110 SemanticSelection.cpp
112 SystemIncludeExtractor.cpp
117 ${COMPLETIONMODEL_SOURCES}
120 index/BackgroundIndexLoader.cpp
121 index/BackgroundIndexStorage.cpp
122 index/BackgroundQueue.cpp
123 index/BackgroundRebuild.cpp
124 index/CanonicalIncludes.cpp
127 index/IndexAction.cpp
130 index/ProjectAware.cpp
133 index/Serialization.cpp
136 index/SymbolCollector.cpp
138 index/SymbolLocation.cpp
139 index/SymbolOrigin.cpp
140 index/YAMLSerialization.cpp
143 index/dex/Iterator.cpp
144 index/dex/PostingList.cpp
145 index/dex/Trigram.cpp
147 refactor/InsertionPoint.cpp
156 # Include generated CompletionModel headers.
157 target_include_directories(clangDaemon PUBLIC
158 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
161 clang_target_link_libraries(clangDaemon
166 clangDependencyScanning
176 clangToolingInclusions
177 clangToolingInclusionsStdlib
181 target_link_libraries(clangDaemon
191 if(CLANGD_TIDY_CHECKS)
192 target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS})
195 add_subdirectory(refactor/tweaks)
196 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
197 # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
198 add_subdirectory(fuzzer)
200 add_subdirectory(tool)
201 add_subdirectory(indexer)
203 if (LLVM_INCLUDE_BENCHMARKS)
204 add_subdirectory(benchmarks)
206 if ( CLANGD_BUILD_XPC )
207 add_subdirectory(xpc)
210 if (CLANGD_ENABLE_REMOTE)
214 if(CLANG_INCLUDE_TESTS)
215 add_subdirectory(test)
216 add_subdirectory(unittests)
219 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
220 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
221 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
223 add_subdirectory(index/remote)
224 add_subdirectory(index/dex/dexp)