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 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(
28 ENABLE_GRPC_REFLECTION
35 ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
36 ${CMAKE_CURRENT_BINARY_DIR}/Features.inc
39 set(LLVM_LINK_COMPONENTS
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
53 include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/../clang-tidy")
55 add_clang_library(clangDaemon
61 CodeCompletionStrings.cpp
81 GlobalCompilationDatabase.cpp
83 HeaderSourceSwitch.cpp
97 SemanticHighlighting.cpp
100 QueryDriverDatabase.cpp
105 ${CMAKE_CURRENT_BINARY_DIR}/CompletionModel.cpp
108 index/BackgroundIndexLoader.cpp
109 index/BackgroundIndexStorage.cpp
110 index/BackgroundQueue.cpp
111 index/BackgroundRebuild.cpp
112 index/CanonicalIncludes.cpp
115 index/IndexAction.cpp
118 index/ProjectAware.cpp
121 index/Serialization.cpp
124 index/SymbolCollector.cpp
126 index/SymbolLocation.cpp
127 index/SymbolOrigin.cpp
128 index/YAMLSerialization.cpp
131 index/dex/Iterator.cpp
132 index/dex/PostingList.cpp
133 index/dex/Trigram.cpp
135 refactor/InsertionPoint.cpp
143 # Include generated CompletionModel headers.
144 target_include_directories(clangDaemon PUBLIC
145 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
148 clang_target_link_libraries(clangDaemon
162 clangToolingInclusions
166 target_link_libraries(clangDaemon
176 if(CLANGD_TIDY_CHECKS)
177 target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS})
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)
185 add_subdirectory(tool)
186 add_subdirectory(indexer)
188 if (LLVM_INCLUDE_BENCHMARKS)
189 add_subdirectory(benchmarks)
191 if ( CLANGD_BUILD_XPC )
192 add_subdirectory(xpc)
195 if (CLANGD_ENABLE_REMOTE)
199 if(CLANG_INCLUDE_TESTS)
200 add_subdirectory(test)
201 add_subdirectory(unittests)
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)