| 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}) |
| 4 |
|
| 5 |
add_subdirectory(support) |
| 6 |
|
| 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 () |
| 14 |
|
| 15 |
llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC_DEFAULT) |
| 16 |
|
| 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 () |
| 20 |
|
| 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) |
| 26 |
|
| 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 |
| 35 |
) |
| 36 |
|
| 37 |
configure_file( |
| 38 |
${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in |
| 39 |
${CMAKE_CURRENT_BINARY_DIR}/Features.inc |
| 40 |
) |
| 41 |
|
| 42 |
set(LLVM_LINK_COMPONENTS |
| 43 |
Support |
| 44 |
AllTargetsInfos |
| 45 |
FrontendOpenMP |
| 46 |
Option |
| 47 |
TargetParser |
| 48 |
) |
| 49 |
|
| 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() |
| 56 |
|
| 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() |
| 60 |
|
| 61 |
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/../clang-tidy") |
| 62 |
include_directories(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../include-cleaner/include") |
| 63 |
|
| 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 |
PathMapping.cpp |
| 101 |
Protocol.cpp |
| 102 |
Quality.cpp |
| 103 |
ParsedAST.cpp |
| 104 |
Preamble.cpp |
| 105 |
RIFF.cpp |
| 106 |
Selection.cpp |
| 107 |
SemanticHighlighting.cpp |
| 108 |
SemanticSelection.cpp |
| 109 |
SourceCode.cpp |
| 110 |
SystemIncludeExtractor.cpp |
| 111 |
TidyProvider.cpp |
| 112 |
TUScheduler.cpp |
| 113 |
URI.cpp |
| 114 |
XRefs.cpp |
| 115 |
${COMPLETIONMODEL_SOURCES} |
| 116 |
|
| 117 |
index/Background.cpp |
| 118 |
index/BackgroundIndexLoader.cpp |
| 119 |
index/BackgroundIndexStorage.cpp |
| 120 |
index/BackgroundQueue.cpp |
| 121 |
index/BackgroundRebuild.cpp |
| 122 |
index/CanonicalIncludes.cpp |
| 123 |
index/FileIndex.cpp |
| 124 |
index/Index.cpp |
| 125 |
index/IndexAction.cpp |
| 126 |
index/MemIndex.cpp |
| 127 |
index/Merge.cpp |
| 128 |
index/ProjectAware.cpp |
| 129 |
index/Ref.cpp |
| 130 |
index/Relation.cpp |
| 131 |
index/Serialization.cpp |
| 132 |
index/StdLib.cpp |
| 133 |
index/Symbol.cpp |
| 134 |
index/SymbolCollector.cpp |
| 135 |
index/SymbolID.cpp |
| 136 |
index/SymbolLocation.cpp |
| 137 |
index/SymbolOrigin.cpp |
| 138 |
index/YAMLSerialization.cpp |
| 139 |
|
| 140 |
index/dex/Dex.cpp |
| 141 |
index/dex/Iterator.cpp |
| 142 |
index/dex/PostingList.cpp |
| 143 |
index/dex/Trigram.cpp |
| 144 |
|
| 145 |
refactor/InsertionPoint.cpp |
| 146 |
refactor/Rename.cpp |
| 147 |
refactor/Tweak.cpp |
| 148 |
|
| 149 |
DEPENDS |
| 150 |
omp_gen |
| 151 |
) |
| 152 |
|
| 153 |
# Include generated CompletionModel headers. |
| 154 |
target_include_directories(clangDaemon PUBLIC |
| 155 |
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> |
| 156 |
) |
| 157 |
|
| 158 |
clang_target_link_libraries(clangDaemon |
| 159 |
PRIVATE |
| 160 |
clangAST |
| 161 |
clangASTMatchers |
| 162 |
clangBasic |
| 163 |
clangDriver |
| 164 |
clangFormat |
| 165 |
clangFrontend |
| 166 |
clangIndex |
| 167 |
clangLex |
| 168 |
clangSema |
| 169 |
clangSerialization |
| 170 |
clangTooling |
| 171 |
clangToolingCore |
| 172 |
clangToolingInclusions |
| 173 |
clangToolingInclusionsStdlib |
| 174 |
clangToolingSyntax |
| 175 |
) |
| 176 |
|
| 177 |
target_link_libraries(clangDaemon |
| 178 |
PRIVATE |
| 179 |
${LLVM_PTHREAD_LIB} |
| 180 |
|
| 181 |
clangIncludeCleaner |
| 182 |
clangPseudo |
| 183 |
clangTidy |
| 184 |
|
| 185 |
clangdSupport |
| 186 |
) |
| 187 |
if(CLANGD_TIDY_CHECKS) |
| 188 |
target_link_libraries(clangDaemon PRIVATE ${ALL_CLANG_TIDY_CHECKS}) |
| 189 |
endif() |
| 190 |
|
| 191 |
add_subdirectory(refactor/tweaks) |
| 192 |
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
| 193 |
# FIXME: Make fuzzer not use linux-specific APIs, build it everywhere. |
| 194 |
add_subdirectory(fuzzer) |
| 195 |
endif() |
| 196 |
add_subdirectory(tool) |
| 197 |
add_subdirectory(indexer) |
| 198 |
|
| 199 |
if (LLVM_INCLUDE_BENCHMARKS) |
| 200 |
add_subdirectory(benchmarks) |
| 201 |
endif() |
| 202 |
if ( CLANGD_BUILD_XPC ) |
| 203 |
add_subdirectory(xpc) |
| 204 |
endif () |
| 205 |
|
| 206 |
if (CLANGD_ENABLE_REMOTE) |
| 207 |
include(AddGRPC) |
| 208 |
endif() |
| 209 |
|
| 210 |
if(CLANG_INCLUDE_TESTS) |
| 211 |
add_subdirectory(test) |
| 212 |
add_subdirectory(unittests) |
| 213 |
endif() |
| 214 |
|
| 215 |
# FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable. |
| 216 |
option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF) |
| 217 |
set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.") |
| 218 |
|
| 219 |
add_subdirectory(index/remote) |
| 220 |
add_subdirectory(index/dex/dexp) |