Skip to content

Commit

Permalink
Rename libclang dependency on Linux
Browse files Browse the repository at this point in the history
When loading our library on Linux, the dynamic linker will look for libclang.so.4, not libclang.so.4.0.
  • Loading branch information
micbou committed Mar 14, 2017
1 parent c441d46 commit 39fce80
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cpp/ycm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ if ( USE_CLANG_COMPLETER AND
NOT PATH_TO_LLVM_ROOT AND
NOT EXTERNAL_LIBCLANG_PATH )

set( CLANG_VERSION "4.0.0" )
set( CLANG_MAJOR_VERSION 4 )
set( CLANG_MINOR_VERSION 0 )
set( CLANG_PATCH_VERSION 0 )
set( CLANG_VERSION
"${CLANG_MAJOR_VERSION}.${CLANG_MINOR_VERSION}.${CLANG_PATCH_VERSION}" )

if ( APPLE )
set( CLANG_DIRNAME "clang+llvm-${CLANG_VERSION}-x86_64-apple-darwin" )
Expand Down Expand Up @@ -296,7 +300,7 @@ if ( EXTERNAL_LIBCLANG_PATH OR USE_SYSTEM_LIBCLANG )
set( EXTERNAL_LIBCLANG_PATH ${TEMP} )
else()
# For Macs, we do things differently; look further in this file.
if ( NOT APPLE )
if ( NOT APPLE AND NOT MSVC )
# Setting this to true makes sure that libraries we build will have our
# rpath set even without having to do "make install"
set( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
Expand All @@ -306,15 +310,18 @@ if ( EXTERNAL_LIBCLANG_PATH OR USE_SYSTEM_LIBCLANG )
# our libraries require, in particular the Python one (from pyenv for
# instance).
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
# When loading our library, the dynamic linker will look for
# libclang.so.4, not libclang.so.4.x.
file( RENAME
${EXTERNAL_LIBCLANG_PATH}.${CLANG_MAJOR_VERSION}.${CLANG_MINOR_VERSION}
${EXTERNAL_LIBCLANG_PATH}.${CLANG_MAJOR_VERSION} )
endif()
endif()

# In Clang 3.7, the library target is a symlink of the soversion one.
# Since it will be copied in the project folder, we need the symlinked
# library.
# On Linux, the library target is a symlink of the soversion one. Since it
# will be copied in the project folder, we need the symlinked library.
get_filename_component( LIBCLANG_TARGET "${EXTERNAL_LIBCLANG_PATH}" REALPATH )
message(
"Using external libclang: ${LIBCLANG_TARGET}" )
message( "Using external libclang: ${LIBCLANG_TARGET}" )
else()
set( LIBCLANG_TARGET )
endif()
Expand Down

0 comments on commit 39fce80

Please sign in to comment.