[PATCH] D13841: [CMake] Bug 25059 - CMake libllvm.so.$MAJOR.$MINOR shared object name not compatible with ldconfig

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 19 13:42:31 PDT 2015


beanz updated this revision to Diff 37789.
beanz added a comment.

Updates based on feedback from Tom and a bug fix for installing the symlinks. Turns out I need to add the symlink install actions after the library is installed otherwise the cmake commands to make the links fails.

With this change the output lib directory has these files:
-rwxr-xr-x  1 cbieneman  staff  40585176 Oct 19 13:22 libLLVM-3.8.0svn.dylib
lrwxr-xr-x  1 cbieneman  staff        16 Oct 19 13:37 libLLVM.dylib -> libLLVM3.8.dylib
lrwxr-xr-x  1 cbieneman  staff        22 Oct 19 13:37 libLLVM3.8.dylib -> libLLVM-3.8.0svn.dylib


http://reviews.llvm.org/D13841

Files:
  cmake/modules/AddLLVM.cmake

Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -542,6 +542,22 @@
                                   -DCMAKE_INSTALL_COMPONENT=${name}
                                   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
       endif()
+      if(ARG_SHARED AND UNIX)
+        # Disable CMake's builtin SO versioning. Historically LLVM hasn't used so
+        # versioning on Darwin, and linux so versioning is hand-rolled.
+        set_target_properties(${name} PROPERTIES NO_SONAME On)
+        if(NOT APPLE)
+          set(library_name ${name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
+          set(api_name ${name}${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
+          set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name})
+          llvm_install_library_symlink(${api_name} ${library_name} SHARED
+            COMPONENT ${name}
+            ALWAYS_GENERATE)
+          llvm_install_library_symlink(${name} ${api_name} SHARED
+            COMPONENT ${name}
+            ALWAYS_GENERATE)
+        endif()
+      endif()
     endif()
     set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
   endif()
@@ -1029,6 +1045,41 @@
   endif()
 endfunction()
 
+function(llvm_install_library_symlink name dest type)
+  cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
+  foreach(path ${CMAKE_MODULE_PATH})
+    if(EXISTS ${path}/LLVMInstallSymlink.cmake)
+      set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
+      break()
+    endif()
+  endforeach()
+
+  set(component ${ARG_COMPONENT})
+  if(NOT component)
+    set(component ${name})
+  endif()
+
+  set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
+  set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
+
+  set(output_dir lib)
+  if(WIN32 AND "${type}" STREQUAL "SHARED")
+    set(output_dir bin)
+  endif()
+
+  install(SCRIPT ${INSTALL_SYMLINK}
+          CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
+          COMPONENT ${component})
+
+  if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
+    add_custom_target(install-${name}
+                      DEPENDS ${name} ${dest} install-${dest}
+                      COMMAND "${CMAKE_COMMAND}"
+                              -DCMAKE_INSTALL_COMPONENT=${name}
+                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  endif()
+endfunction()
+
 function(llvm_install_symlink name dest)
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13841.37789.patch
Type: text/x-patch
Size: 2723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151019/1f8960cf/attachment-0001.bin>


More information about the llvm-commits mailing list