Skip to content

[clangd] Use clang_target_link_libraries() for clang libs #94937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Jun 10, 2024

Use clang_target_link_libraries() instead of LINK_LIBS when linking clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB mode we link against libclang-cpp.so (instead of linking against both it and the static libraries).

Most places were already doing this correctly, there were just a handful of leftovers.

Use clang_target_link_libraries() instead of LINK_LIBS when
linking clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB
mode we link against libclang-cpp.so (instead of linking against
both it and the static libraries).

Most places were already doing this correctly, there were just
a handful of leftovers.
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2024

@llvm/pr-subscribers-clangd

@llvm/pr-subscribers-clang-tools-extra

Author: Nikita Popov (nikic)

Changes

Use clang_target_link_libraries() instead of LINK_LIBS when linking clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB mode we link against libclang-cpp.so (instead of linking against both it and the static libraries).

Most places were already doing this correctly, there were just a handful of leftovers.


Full diff: https://github.com/llvm/llvm-project/pull/94937.diff

3 Files Affected:

  • (modified) clang-tools-extra/clangd/index/remote/CMakeLists.txt (+5-1)
  • (modified) clang-tools-extra/pseudo/lib/CMakeLists.txt (+6-2)
  • (modified) clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt (+5-1)
diff --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index ed6269d2ccaa9..106bbeff84ccf 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -26,7 +26,6 @@ if (CLANGD_ENABLE_REMOTE)
     clangdRemoteIndexProto
     clangdRemoteIndexServiceProto
     clangdRemoteMarshalling
-    clangBasic
     clangDaemon
     clangdSupport
 
@@ -35,6 +34,11 @@ if (CLANGD_ENABLE_REMOTE)
     clangdRemoteIndexServiceProto
     )
 
+  clang_target_link_libraries(clangdRemoteIndex
+    PRIVATE
+    clangBasic
+    )
+
   add_subdirectory(marshalling)
   add_subdirectory(server)
   add_subdirectory(monitor)
diff --git a/clang-tools-extra/pseudo/lib/CMakeLists.txt b/clang-tools-extra/pseudo/lib/CMakeLists.txt
index f92f79be12150..a13b5d20cf7c3 100644
--- a/clang-tools-extra/pseudo/lib/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/lib/CMakeLists.txt
@@ -14,8 +14,6 @@ add_clang_library(clangPseudo
   Token.cpp
 
   LINK_LIBS
-  clangBasic
-  clangLex
   clangPseudoGrammar
 
   DEPENDS
@@ -25,3 +23,9 @@ add_clang_library(clangPseudo
   target_include_directories(clangPseudo INTERFACE
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
   )
+
+clang_target_link_libraries(clangPseudo
+  PRIVATE
+  clangBasic
+  clangLex
+  )
diff --git a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
index d56d16c893c3d..2fecdce6a10f9 100644
--- a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
@@ -9,7 +9,11 @@ add_clang_library(clangPseudoCXX
   cxx_gen
 
   LINK_LIBS
-  clangBasic
   clangPseudo
   clangPseudoGrammar
   )
+
+clang_target_link_libraries(clangPseudoCXX
+  PRIVATE
+  clangBasic
+  )

@nikic nikic merged commit 34033dc into llvm:main Jun 11, 2024
10 checks passed
@nikic nikic deleted the clangd-libs branch June 11, 2024 06:08
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Jun 12, 2024
Use clang_target_link_libraries() instead of LINK_LIBS when linking
clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB mode we
link against libclang-cpp.so (instead of linking against both it and the
static libraries).

Most places were already doing this correctly, there were just a handful
of leftovers.
@HerrCai0907 HerrCai0907 mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants