mirror of
https://git.tukaani.org/xz.git
synced 2025-03-23 08:50:43 +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:
parent
4243c45a48
commit
c1ea7bd0b6
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user