From: Jakub Jirutka Date: Sun, 07 Aug 2016 12:37:00 +0200 Subject: [PATCH] Include version in name of shared libs This change makes the CMake build system generate libraries for Linux and Darwin matching the makefile build system. libLLVM.so -> libLLVM-$MAJOR.$MINOR.so libLTO.so -> libLTO-$MAJOR.$MINOR.so See https://github.com/llvm-mirror/llvm/commit/61dbca10ea813ea3af447cc7ac2556a5e81211f9 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -313,10 +313,12 @@ # Same semantics as target_link_libraries(). # ADDITIONAL_HEADERS # May specify header files for IDE generators. +# SONAME +# Should set SONAME link flags and create symlinks # ) function(llvm_add_library name) cmake_parse_arguments(ARG - "MODULE;SHARED;STATIC" + "MODULE;SHARED;STATIC;SONAME" "OUTPUT_NAME" "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS" ${ARGN}) @@ -418,11 +420,6 @@ PREFIX "" ) endif() - - 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() if(ARG_MODULE OR ARG_SHARED) @@ -483,7 +480,7 @@ macro(add_llvm_library name) cmake_parse_arguments(ARG - "SHARED" + "SHARED;SONAME" "" "" ${ARGN}) @@ -526,6 +523,15 @@ -DCMAKE_INSTALL_COMPONENT=${name} -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") endif() + if(ARG_SHARED) + get_target_property(output_name ${name} OUTPUT_NAME) + if(${output_name} STREQUAL "output_name-NOTFOUND") + set(output_name ${name}) + endif() + set(library_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}) + set(api_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) + set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name}) + endif() endif() set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) endif() --- a/tools/llvm-shlib/CMakeLists.txt +++ b/tools/llvm-shlib/CMakeLists.txt @@ -95,7 +95,7 @@ add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE}) endif() -add_llvm_library(LLVM SHARED ${SOURCES}) +add_llvm_library(LLVM SHARED SONAME ${SOURCES}) list(REMOVE_DUPLICATES LIB_NAMES) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf"