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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
From 889531a776155aec2a36a6cf47183dea90549759 Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Mon, 4 Jul 2016 08:32:42 -0600
Subject: [PATCH] backport so versioning
---
cmake/modules/AddLLVM.cmake | 93 +++++++++++++++++++++++++++++++---
cmake/modules/LLVMInstallSymlink.cmake | 21 ++++++++
tools/llvm-shlib/CMakeLists.txt | 2 +-
3 files changed, 109 insertions(+), 7 deletions(-)
create mode 100644 cmake/modules/LLVMInstallSymlink.cmake
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 6b6e6e0..b9d67d9 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -316,10 +316,12 @@ endfunction(set_windows_version_resource_properties)
# 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;DISABLE_LLVM_LINK_LLVM_DYLIB"
+ "MODULE;SHARED;STATIC;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
"OUTPUT_NAME"
"ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
${ARGN})
@@ -421,11 +423,6 @@ function(llvm_add_library name)
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)
@@ -440,6 +437,24 @@ function(llvm_add_library name)
endif()
endif()
+ if(ARG_SHARED AND UNIX)
+ if(NOT APPLE AND ARG_SONAME)
+ 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})
+ llvm_install_library_symlink(${api_name} ${library_name} SHARED
+ COMPONENT ${name}
+ ALWAYS_GENERATE)
+ llvm_install_library_symlink(${output_name} ${library_name} SHARED
+ COMPONENT ${name}
+ ALWAYS_GENERATE)
+ endif()
+ endif()
+
# Add the explicit dependency information for this library.
#
# It would be nice to verify that we have the dependencies for this library
@@ -970,3 +985,69 @@ function(add_lit_testsuites project directory)
endforeach()
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})
+ if(EXISTS ${path}/LLVMInstallSymlink.cmake)
+ set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
+ break()
+ endif()
+ endforeach()
+
+ if(ARG_ALWAYS_GENERATE)
+ set(component ${dest})
+ else()
+ set(component ${name})
+ endif()
+
+ set(full_name ${name}${CMAKE_EXECUTABLE_SUFFIX})
+ set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
+
+ install(SCRIPT ${INSTALL_SYMLINK}
+ CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_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()
diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
new file mode 100644
index 0000000..482697b
--- /dev/null
+++ b/cmake/modules/LLVMInstallSymlink.cmake
@@ -0,0 +1,21 @@
+# We need to execute this script at installation time because the
+# DESTDIR environment variable may be unset at configuration time.
+# See PR8397.
+
+function(install_symlink name target outdir)
+ if(UNIX)
+ set(LINK_OR_COPY create_symlink)
+ set(DESTDIR $ENV{DESTDIR})
+ else()
+ set(LINK_OR_COPY copy)
+ endif()
+
+ set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
+
+ message("Creating ${name}")
+
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
+ WORKING_DIRECTORY "${bindir}")
+
+endfunction()
diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt
index 9b407bd..d47a01f 100644
--- a/tools/llvm-shlib/CMakeLists.txt
+++ b/tools/llvm-shlib/CMakeLists.txt
@@ -82,7 +82,7 @@ else()
add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE})
endif()
-add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB ${SOURCES})
+add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
list(REMOVE_DUPLICATES LIB_NAMES)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf"
--
2.9.0
|