Skip to content

Commit

Permalink
Link against libclang-cpp.so when linking with shared libraries
Browse files Browse the repository at this point in the history
libclang-cpp.so is a new shared object in clang-9.0.0 which
contains all the clang components in one library.  Doing this will
save us from having to update cmake when there is a new clang component
and may provide better performance in LTO builds of clang.
  • Loading branch information
tstellar authored and franz committed Mar 25, 2020
1 parent 60d7b13 commit 79bf0ab
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmake/LLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,16 @@ string(REPLACE " -pedantic" "" LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")
string(REGEX REPLACE "-W[^ ]*" "" LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")

# Llvm-config does not include clang libs
set(CLANG_LIBNAMES clangCodeGen clangFrontendTool clangFrontend clangDriver clangSerialization
clangParse clangSema clangRewrite clangRewriteFrontend
clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers
clangStaticAnalyzerCore clangAnalysis clangEdit clangAST clangASTMatchers clangLex clangBasic)
if((9 LESS LLVM_MAJOR) AND (LLVM_LIB_IS_SHARED MATCHES "shared"))
# Link against a single shared library instead of multiple component shared
# libraries.
set(CLANG_LIBNAMES clang-cpp)
else()
set(CLANG_LIBNAMES clangCodeGen clangFrontendTool clangFrontend clangDriver clangSerialization
clangParse clangSema clangRewrite clangRewriteFrontend
clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers
clangStaticAnalyzerCore clangAnalysis clangEdit clangAST clangASTMatchers clangLex clangBasic)
endif()

foreach(LIBNAME ${CLANG_LIBNAMES})
find_library(C_LIBFILE_${LIBNAME} NAMES "${LIBNAME}" HINTS "${LLVM_LIBDIR}")
Expand Down

0 comments on commit 79bf0ab

Please sign in to comment.