CMake: Disable symbol versioning on non-glibc Linux.

This better matches what configure.ac does. For example, musl has
only basic symbol versioning support:

https://wiki.musl-libc.org/functional-differences-from-glibc.html#Symbol_versioning

configure.ac tries to enable symbol versioning only with glibc
so now CMake does the same.

(cherry picked from commit 2ad7fad670)
This commit is contained in:
Lasse Collin 2024-03-13 21:17:10 +02:00
parent 4b3c84e8ee
commit 1888fb49f6
1 changed files with 20 additions and 2 deletions

View File

@ -358,8 +358,26 @@ if(NOT WIN32)
# This includes a few extra compatibility symbols for RHEL/CentOS 7 # This includes a few extra compatibility symbols for RHEL/CentOS 7
# which are pointless on non-glibc non-Linux systems. # which are pointless on non-glibc non-Linux systems.
# #
# FIXME? Avoid symvers on Linux with non-glibc like musl? # Avoid symvers on Linux with non-glibc like musl and uClibc.
# In Autoconf it's enough to check that $host_os equals linux-gnu
# instead of, for example, linux-musl. CMake doesn't provide such
# a method.
#
# This check is here for now since it's not strictly required
# by anything else.
check_c_source_compiles(
"#include <features.h>
#if defined(__GLIBC__) && !defined(__UCLIBC__)
int main(void) { return 0; }
#else
compile error
#endif
"
IS_LINUX_WITH_GLIBC)
if(IS_LINUX_WITH_GLIBC)
set(SYMBOL_VERSIONING_DEFAULT "linux") set(SYMBOL_VERSIONING_DEFAULT "linux")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SYMBOL_VERSIONING_DEFAULT "generic") set(SYMBOL_VERSIONING_DEFAULT "generic")