Fix builds for LLVM 9 (for LLVM build without BUILD_SHARED_LIBS=ON)

LLVM 9 officially ships the C++ libraries as a single library
libclang-cpp.so. This makes ccls fail to link as the individual libraries
libclangIndex, libclangFormat, etc. are no longer present.

We use clang-cpp if it is available and fallback to the previously used
behavior if clang-cpp is not available.
This commit is contained in:
Dan Čermák 2019-11-01 10:02:57 +01:00
parent bfac2162eb
commit 7381df3bdd
No known key found for this signature in database
GPG Key ID: E632C3380610D1C5

View File

@ -68,8 +68,17 @@ endif()
### Libraries
# LLVM >= 9 ships the C++ libraries by default in a single library libclang-cpp,
# but this is not universally enabled on all distributions.
# If clang-cpp is available, then link against it, otherwise link against the
# individual clang libraries.
find_package(Clang REQUIRED)
if(TARGET clang-cpp AND NOT TARGET clangBasic)
target_link_libraries(ccls PRIVATE
clang-cpp
)
else()
target_link_libraries(ccls PRIVATE
clangIndex
clangFormat
@ -85,6 +94,7 @@ target_link_libraries(ccls PRIVATE
clangDriver
clangBasic
)
endif()
if(LLVM_LINK_LLVM_DYLIB)
target_link_libraries(ccls PRIVATE LLVM)