]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Revise tuklib_use_system_extensions
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 9 Mar 2025 12:06:35 +0000 (14:06 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 9 Mar 2025 15:44:31 +0000 (17:44 +0200)
Define NetBSD and Darwin/macOS feature test macros. Autoconf defines
these too (and a few others).

Define the macros on Windows except with MSVC. The _GNU_SOURCE macro
makes a difference with mingw-w64.

Use a function instead of a macro. Don't take the TARGET_OR_ALL argument
because there's always global effect because the global variable
CMAKE_REQUIRED_DEFINITIONS is modified.

CMakeLists.txt
cmake/tuklib_common.cmake

index 3de1321fbbd9aa4554d3c01b43663ba080965ac8..32506cdd5611899d5cbd01870057935fbee7734d 100644 (file)
@@ -286,7 +286,7 @@ endif()
 
 # _GNU_SOURCE and such definitions. This specific macro is special since
 # it also adds the definitions to CMAKE_REQUIRED_DEFINITIONS.
-tuklib_use_system_extensions(ALL)
+tuklib_use_system_extensions()
 
 # Check for large file support. It's required on some 32-bit platforms and
 # even on 64-bit MinGW-w64 to get 64-bit off_t. This can be forced off on
index a7f101fa836ee18abf8e5c9af6a8c7b7d7ff50b3..b575506aecbcfcc68fdbf66b11eb38d7a213d7f0 100644 (file)
@@ -26,25 +26,28 @@ endfunction()
 
 # This is an over-simplified version of AC_USE_SYSTEM_EXTENSIONS in Autoconf
 # or gl_USE_SYSTEM_EXTENSIONS in gnulib.
-macro(tuklib_use_system_extensions TARGET_OR_ALL)
-    if(NOT WIN32)
-        # FIXME? The Solaris-specific __EXTENSIONS__ should be conditional
-        #        even on Solaris. See gnulib: git log m4/extensions.m4.
-        # FIXME? gnulib and autoconf.git has lots of new stuff.
-        tuklib_add_definitions("${TARGET_OR_ALL}"
-            _GNU_SOURCE
-            __EXTENSIONS__
-            _POSIX_PTHREAD_SEMANTICS
-            _TANDEM_SOURCE
-            _ALL_SOURCE
+function(tuklib_use_system_extensions)
+    if(NOT MSVC)
+        add_compile_definitions(
+            _GNU_SOURCE        # glibc, musl, mingw-w64
+            _NETBSD_SOURCE     # NetBSD, MINIX 3
+            _OPENBSD_SOURCE    # Also NetBSD!
+            __EXTENSIONS__     # Solaris
+            _POSIX_PTHREAD_SEMANTICS # Solaris
+            _DARWIN_C_SOURCE   # macOS
+            _TANDEM_SOURCE     # HP NonStop
+            _ALL_SOURCE        # AIX, z/OS
         )
 
         list(APPEND CMAKE_REQUIRED_DEFINITIONS
             -D_GNU_SOURCE
+            -D_NETBSD_SOURCE
+            -D_OPENBSD_SOURCE
             -D__EXTENSIONS__
             -D_POSIX_PTHREAD_SEMANTICS
+            -D_DARWIN_C_SOURCE
             -D_TANDEM_SOURCE
             -D_ALL_SOURCE
         )
     endif()
-endmacro()
+endfunction()