[clang-tools-extra] [clangd] Add dynamic plugins support (PR #226995)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 04:09:20 PDT 2026


================
@@ -30,6 +30,36 @@ foreach(dep FileCheck count not llvm-config)
   endif()
 endforeach()
 
+if (NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB)
+  llvm_add_library(
+      ClangdFeatureModuleExample
+      MODULE FeatureModuleExample.cpp
+      PLUGIN_TOOL clangd
+      PARTIAL_SOURCES_INTENDED)
+  llvm_add_library(
+      ClangdStandaloneTweakExample
+      MODULE StandaloneTweakExample.cpp
+      PLUGIN_TOOL clangd
+      PARTIAL_SOURCES_INTENDED)
+endif()
+
+foreach(target ClangdFeatureModuleExample ClangdStandaloneTweakExample)
+  if(TARGET ${target})
+    list(APPEND CLANGD_TEST_DEPS ${target})
+    target_include_directories(${target} PUBLIC BEFORE
+      "${CLANG_TOOLS_SOURCE_DIR}/clangd"
+      "${CMAKE_CURRENT_BINARY_DIR}/.."
+    )
+    if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+      set(LLVM_LINK_COMPONENTS
+        Support
+      )
+    endif()
+  endif()
+endforeach()
+
+llvm_canonicalize_cmake_booleans(CLANG_PLUGIN_SUPPORT)
----------------
timon-ul wrote:

Well I was mainly asking because I indeed expect us to not support clang plugins, but the name kinda could be interpret as the opposite (at least to someone as naiive as me). That being said I guess overall it makes sense to use this.

https://github.com/llvm/llvm-project/pull/226995


More information about the cfe-commits mailing list