aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2024-03-13 21:17:10 +0200
committerLasse Collin <lasse.collin@tukaani.org>2024-03-15 17:30:50 +0200
commit2ad7fad67080e88fa7fc191f9d613d8b7add9c62 (patch)
treec9d87949da2f079967e21dfe1d0148762e38fc59 /CMakeLists.txt
parentCMake: Make symbol versioning configurable. (diff)
downloadxz-2ad7fad67080e88fa7fc191f9d613d8b7add9c62.tar.xz
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.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt22
1 files changed, 20 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4da57773..cc626b41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -358,8 +358,26 @@ if(NOT WIN32)
# This includes a few extra compatibility symbols for RHEL/CentOS 7
# which are pointless on non-glibc non-Linux systems.
#
- # FIXME? Avoid symvers on Linux with non-glibc like musl?
- set(SYMBOL_VERSIONING_DEFAULT "linux")
+ # 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")
+ endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SYMBOL_VERSIONING_DEFAULT "generic")