1
0
mirror of https://git.tukaani.org/xz.git synced 2025-03-25 09:50:41 +00:00

CMake: Revise tuklib_use_system_extensions

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.
This commit is contained in:
Lasse Collin 2025-03-09 14:06:35 +02:00
parent 4243c45a48
commit c1ea7bd0b6
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
2 changed files with 16 additions and 13 deletions

View File

@ -286,7 +286,7 @@ endif()
# _GNU_SOURCE and such definitions. This specific macro is special since # _GNU_SOURCE and such definitions. This specific macro is special since
# it also adds the definitions to CMAKE_REQUIRED_DEFINITIONS. # 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 # 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 # even on 64-bit MinGW-w64 to get 64-bit off_t. This can be forced off on

View File

@ -26,25 +26,28 @@ endfunction()
# This is an over-simplified version of AC_USE_SYSTEM_EXTENSIONS in Autoconf # This is an over-simplified version of AC_USE_SYSTEM_EXTENSIONS in Autoconf
# or gl_USE_SYSTEM_EXTENSIONS in gnulib. # or gl_USE_SYSTEM_EXTENSIONS in gnulib.
macro(tuklib_use_system_extensions TARGET_OR_ALL) function(tuklib_use_system_extensions)
if(NOT WIN32) if(NOT MSVC)
# FIXME? The Solaris-specific __EXTENSIONS__ should be conditional add_compile_definitions(
# even on Solaris. See gnulib: git log m4/extensions.m4. _GNU_SOURCE # glibc, musl, mingw-w64
# FIXME? gnulib and autoconf.git has lots of new stuff. _NETBSD_SOURCE # NetBSD, MINIX 3
tuklib_add_definitions("${TARGET_OR_ALL}" _OPENBSD_SOURCE # Also NetBSD!
_GNU_SOURCE __EXTENSIONS__ # Solaris
__EXTENSIONS__ _POSIX_PTHREAD_SEMANTICS # Solaris
_POSIX_PTHREAD_SEMANTICS _DARWIN_C_SOURCE # macOS
_TANDEM_SOURCE _TANDEM_SOURCE # HP NonStop
_ALL_SOURCE _ALL_SOURCE # AIX, z/OS
) )
list(APPEND CMAKE_REQUIRED_DEFINITIONS list(APPEND CMAKE_REQUIRED_DEFINITIONS
-D_GNU_SOURCE -D_GNU_SOURCE
-D_NETBSD_SOURCE
-D_OPENBSD_SOURCE
-D__EXTENSIONS__ -D__EXTENSIONS__
-D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS
-D_DARWIN_C_SOURCE
-D_TANDEM_SOURCE -D_TANDEM_SOURCE
-D_ALL_SOURCE -D_ALL_SOURCE
) )
endif() endif()
endmacro() endfunction()