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
70 CodeCompletionStrings.cpp
91 GlobalCompilationDatabase.cpp
93 HeaderSourceSwitch.cpp
107 SemanticHighlighting.cpp
108 SemanticSelection.cpp
110 SystemIncludeExtractor.cpp
115 ${COMPLETIONMODEL_SOURCES}
118 index/BackgroundIndexLoader.cpp
119 index/BackgroundIndexStorage.cpp
120 index/BackgroundQueue.cpp
121 index/BackgroundRebuild.cpp
122 index/CanonicalIncludes.cpp
125 index/IndexAction.cpp
128 index/ProjectAware.cpp
131 index/Serialization.cpp
134 index/SymbolCollector.cpp
136 index/SymbolLocation.cpp
137 index/SymbolOrigin.cpp
138 index/YAMLSerialization.cpp
141 index/dex/Iterator.cpp
142 index/dex/PostingList.cpp
143 index/dex/Trigram.cpp
145 refactor/InsertionPoint.cpp
154 # Include generated CompletionModel headers.
155 target_include_directories(clangDaemon PUBLIC
156 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
159 clang_target_link_libraries(clangDaemon
173 clangToolingInclusions
174 clangToolingInclusionsStdlib
178 target_link_libraries(clangDaemon
188 if(CLANGD_TIDY_CHECKS)
189 target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS})
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)
197 add_subdirectory(tool)
198 add_subdirectory(indexer)
200 if (LLVM_INCLUDE_BENCHMARKS)
201 add_subdirectory(benchmarks)
203 if ( CLANGD_BUILD_XPC )
204 add_subdirectory(xpc)
207 if (CLANGD_ENABLE_REMOTE)
211 if(CLANG_INCLUDE_TESTS)
212 add_subdirectory(test)
213 add_subdirectory(unittests)
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)