aboutsummaryrefslogtreecommitdiffstats
path: root/community/llvm3.7/cmake-fix-libLLVM-name.patch
blob: 600e32777f2b41b445981b0fb8b6650e46d3a15b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From: Jakub Jirutka <jakub@jirutka.cz>
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"