[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
Fri Oct 16 19:09:47 PDT 2015
beanz created this revision.
beanz added reviewers: tstellarAMD, loladiro.
beanz added a subscriber: llvm-commits.
This change makes the CMake build system generate libraries for Linux and Darwin matching the makefile build system.
Linux libraries follow the pattern lib${name}.${MAJOR}.${MINOR}.so so that ldconfig won't pick it up incorrectly.
Darwin libraries are not versioned.
Note: On linux the non-versioned symlink is generated at install-time not build time. I plan to fix that eventually, but I expect that is good enough for the purposes of fixing this bug.
http://reviews.llvm.org/D13841
Files:
cmake/modules/AddLLVM.cmake
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -395,6 +395,16 @@
elseif(ARG_SHARED)
add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
add_library(${name} SHARED ${ALL_FILES})
+ if(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})
+ set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name})
+ llvm_install_library_symlink(${name} ${library_name} SHARED ALWAYS_GENERATE)
+ endif()
+ endif()
else()
add_library(${name} STATIC ${ALL_FILES})
endif()
@@ -433,7 +443,6 @@
set_target_properties(${name}
PROPERTIES
- SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}
VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
endif()
@@ -1029,6 +1038,38 @@
endif()
endfunction()
+function(llvm_install_library_symlink name dest type)
+ cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
+ foreach(path ${CMAKE_MODULE_PATH})
+ if(EXISTS ${path}/LLVMInstallSymlink.cmake)
+ set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
+ break()
+ endif()
+ endforeach()
+
+ set(component ${name})
+
+ 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.37668.patch
Type: text/x-patch
Size: 2515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151017/08bfc812/attachment.bin>
More information about the llvm-commits
mailing list