]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Disable symbol versioning on non-glibc Linux.
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 13 Mar 2024 19:17:10 +0000 (21:17 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 15 Mar 2024 15:30:50 +0000 (17:30 +0200)
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.

CMakeLists.txt

index 4da57773c17d35d8c7e69c8efaf5b1c3f9384643..cc626b413e6f7bf4762fe17695a773e6d2d3e845 100644 (file)
@@ -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")