History

Fix CMake generated shared library ABI compliance, closes #116

Use version script to export correct ABI set with CMake. This change is related to Unix shared library builds only (GNUC, Clang and Intel Compilers).

evpobr committed 6 years ago

Commit 144174d1 parent 260c3f62 files · +28 −1Browse files

Unified · Split

2 files
  1. CMakeLists.txt +26 −1
  2. NEWS +2 −0
CMakeLists.txt+26−1
@@ -165,11 +165,36 @@ endif() · 164 unmodified lines
165# Set public header165# Set public header
166set_property(TARGET samplerate PROPERTY PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/src/samplerate.h)166set_property(TARGET samplerate PROPERTY PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/src/samplerate.h)
167 167
168# Set ABI version. This is critical for Unix-like OSes
169if(BUILD_SHARED_LIBS)168if(BUILD_SHARED_LIBS)
169 # Set ABI version. This is critical for Unix-like OSes
170 set_target_properties(samplerate PROPERTIES170 set_target_properties(samplerate PROPERTIES
171 VERSION ${libsamplerate_VERSION}171 VERSION ${libsamplerate_VERSION}
172 SOVERSION ${libsamplerate_VERSION_MAJOR})172 SOVERSION ${libsamplerate_VERSION_MAJOR})
173
174 # Use Version_script to export ABI set
175 if(UNIX AND (NOT APPLE))
176 if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
177 (CMAKE_C_COMPILER_ID STREQUAL "Clang") OR
178 (CMAKE_C_COMPILER_ID STREQUAL "Intel"))
179
180 set(PACKAGE ${PROJECT_NAME})
181 configure_file(src/Version_script.in src/Version_script)
182 unset(PACKAGE)
183
184 if(CMAKE_VERSION VERSION_LESS 3.13)
185 # This works
186 set_property(TARGET samplerate APPEND_STRING PROPERTY
187 LINK_FLAGS "-Wl,--version-script,${PROJECT_BINARY_DIR}/src/Version_script")
188 else()
189 # This works even better, e.g. for Clang it uses `-Xlinker` option,
190 # but requires CMake >= 3.13.
191 target_link_options(samplerate
192 PRIVATE
193 "LINKER:--version-script,${PROJECT_BINARY_DIR}/src/Version_script")
194 endif()
195
196 endif()
197 endif()
173endif()198endif()
174 199
175# Tests200# Tests
NEWS+2−0
@@ -1,5 +1,7 @@
1Unreleased1Unreleased
2 2
3 * CMake:
4 * Fix CMake generated shared library ABI compliance with Autotools build
3 * Documentation:5 * Documentation:
4 * Move site to new URL: http://libsndfile.github.io/libsamplerate/6 * Move site to new URL: http://libsndfile.github.io/libsamplerate/
5 * Convert documentation pages from HTML to Markdown7 * Convert documentation pages from HTML to Markdown

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t