mirror of
https://github.com/curl/curl.git
synced 2026-07-10 07:07:16 +03:00
Also repurpose existing build-time feature checks into unit test 1961,
to verify.
Prior to this patch these functions were auto-detected with both
autotools and cmake. In case of autotools there was an extra
verification phase ensuring the functions work as expected. This step
required running the function, thus was limited to non-cross-builds. For
cross-builds and CMake it always used the system implementation if
present. On Windows it always used the local implementation, because
availability/use is complicated there.
After this patch all platforms, always use the local implementation,
which is known to be accurate. This makes curl behave more consistently,
and simplifies the build process, a fixes cross-builds and CMake
auto-detection differences.
Also:
- test1960: enable unconditionally.
- checksrc: disallow globally, allowlist in `block_ip.c` example.
- dnsd: verify ntop result for NULL before passing to printf.
Ref: https://github.com/curl/curl/pull/22137#issuecomment-4797440983
Ref: #22137
Ref: 8537a5b0bc #16577
Closes #22170
318 lines
8.6 KiB
CMake
318 lines
8.6 KiB
CMake
#***************************************************************************
|
|
# _ _ ____ _
|
|
# Project ___| | | | _ \| |
|
|
# / __| | | | |_) | |
|
|
# | (__| |_| | _ <| |___
|
|
# \___|\___/|_| \_\_____|
|
|
#
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
#
|
|
# This software is licensed as described in the file COPYING, which
|
|
# you should have received as part of this distribution. The terms
|
|
# are also available at https://curl.se/docs/copyright.html.
|
|
#
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
#
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
# KIND, either express or implied.
|
|
#
|
|
# SPDX-License-Identifier: curl
|
|
#
|
|
###########################################################################
|
|
# Based on CI runs for Cygwin/MSYS2, Linux, macOS/iOS, DragonFly BSD, FreeBSD, MidnightBSD, NetBSD, OpenBSD
|
|
if(NOT UNIX)
|
|
message(FATAL_ERROR "This file should be included on Unix platforms only")
|
|
endif()
|
|
|
|
if(APPLE OR
|
|
CYGWIN)
|
|
set(HAVE_ACCEPT4 0)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
set(HAVE_ACCEPT4 1)
|
|
endif()
|
|
set(HAVE_ALARM 1)
|
|
if(ANDROID)
|
|
set(HAVE_ARC4RANDOM 1)
|
|
else()
|
|
set(HAVE_ARC4RANDOM 0)
|
|
endif()
|
|
set(HAVE_ARPA_INET_H 1)
|
|
set(HAVE_ATOMIC 1)
|
|
set(HAVE_BASENAME 1)
|
|
set(HAVE_BOOL_T 1)
|
|
if(NOT APPLE)
|
|
set(HAVE_CLOCK_GETTIME_MONOTONIC 1)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
set(HAVE_CLOCK_GETTIME_MONOTONIC_RAW 1)
|
|
else()
|
|
set(HAVE_CLOCK_GETTIME_MONOTONIC_RAW 0)
|
|
endif()
|
|
endif()
|
|
set(HAVE_CLOSESOCKET 0)
|
|
set(HAVE_DECL_FSEEKO 1)
|
|
set(HAVE_DIRENT_H 1)
|
|
if(APPLE OR
|
|
CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
set(HAVE_EVENTFD 0)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
|
set(HAVE_EVENTFD 1)
|
|
endif()
|
|
if(ANDROID AND ANDROID_PLATFORM_LEVEL GREATER_EQUAL 34)
|
|
set(HAVE_MEMSET_EXPLICIT 1)
|
|
endif()
|
|
if((APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.9) OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR # v6+
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR # v11.2+
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD") # v1.3+
|
|
set(HAVE_MEMSET_S 1)
|
|
elseif(NOT APPLE)
|
|
set(HAVE_MEMSET_S 0)
|
|
endif()
|
|
set(HAVE_FCNTL 1)
|
|
set(HAVE_FCNTL_H 1)
|
|
set(HAVE_FCNTL_O_NONBLOCK 1)
|
|
set(HAVE_FILE_OFFSET_BITS 1)
|
|
set(HAVE_FNMATCH 1)
|
|
set(HAVE_FREEADDRINFO 1)
|
|
set(HAVE_FSEEKO 1)
|
|
if(APPLE)
|
|
set(HAVE_FSETXATTR 1)
|
|
set(HAVE_FSETXATTR_5 0)
|
|
set(HAVE_FSETXATTR_6 1)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
set(HAVE_FSETXATTR 0)
|
|
set(HAVE_FSETXATTR_5 0)
|
|
set(HAVE_FSETXATTR_6 0)
|
|
elseif(CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
|
set(HAVE_FSETXATTR 1)
|
|
set(HAVE_FSETXATTR_5 1)
|
|
set(HAVE_FSETXATTR_6 0)
|
|
endif()
|
|
set(HAVE_GETADDRINFO 1)
|
|
if(CYGWIN)
|
|
set(HAVE_GETADDRINFO_THREADSAFE 1)
|
|
endif()
|
|
set(HAVE_GETEUID 1)
|
|
if(APPLE OR
|
|
CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
set(HAVE_GETHOSTBYNAME_R 0)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
|
|
set(HAVE_GETHOSTBYNAME_R 1)
|
|
endif()
|
|
set(HAVE_GETHOSTBYNAME_R_3 0)
|
|
set(HAVE_GETHOSTBYNAME_R_3_REENTRANT 0)
|
|
set(HAVE_GETHOSTBYNAME_R_5 0)
|
|
set(HAVE_GETHOSTBYNAME_R_5_REENTRANT 0)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
|
|
set(HAVE_GETHOSTBYNAME_R_6 1)
|
|
set(HAVE_GETHOSTBYNAME_R_6_REENTRANT 1)
|
|
else()
|
|
set(HAVE_GETHOSTBYNAME_R_6 0)
|
|
set(HAVE_GETHOSTBYNAME_R_6_REENTRANT 0)
|
|
endif()
|
|
set(HAVE_GETHOSTNAME 1)
|
|
if(NOT ANDROID OR ANDROID_PLATFORM_LEVEL GREATER_EQUAL 24)
|
|
set(HAVE_GETIFADDRS 1)
|
|
else()
|
|
set(HAVE_GETIFADDRS 0)
|
|
endif()
|
|
if(APPLE OR
|
|
CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
set(HAVE_GETPASS_R 0)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
|
set(HAVE_GETPASS_R 1)
|
|
endif()
|
|
set(HAVE_GETPEERNAME 1)
|
|
set(HAVE_GETPPID 1)
|
|
set(HAVE_GETPWUID 1)
|
|
set(HAVE_GETPWUID_R 1)
|
|
set(HAVE_GETRLIMIT 1)
|
|
set(HAVE_GETSOCKNAME 1)
|
|
set(HAVE_GETTIMEOFDAY 1)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
# Depends on C library.
|
|
else()
|
|
set(HAVE_GLIBC_STRERROR_R 0)
|
|
endif()
|
|
set(HAVE_GMTIME_R 1)
|
|
set(HAVE_IFADDRS_H 1)
|
|
set(HAVE_IF_NAMETOINDEX 1)
|
|
set(HAVE_IOCTLSOCKET 0)
|
|
set(HAVE_IOCTLSOCKET_CAMEL 0)
|
|
set(HAVE_IOCTLSOCKET_CAMEL_FIONBIO 0)
|
|
set(HAVE_IOCTLSOCKET_FIONBIO 0)
|
|
set(HAVE_IOCTL_FIONBIO 1)
|
|
set(HAVE_IOCTL_SIOCGIFADDR 1)
|
|
if(CYGWIN)
|
|
set(HAVE_IO_H 1)
|
|
else()
|
|
set(HAVE_IO_H 0)
|
|
endif()
|
|
set(HAVE_LIBGEN_H 1)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
# Requires Linux kernel userspace headers. Expected with glibc. May be missing by default with MUSL.
|
|
else()
|
|
set(HAVE_LINUX_TCP_H 0)
|
|
endif()
|
|
set(HAVE_LOCALE_H 1)
|
|
set(HAVE_LOCALTIME_R 1)
|
|
if(APPLE)
|
|
set(HAVE_MACH_ABSOLUTE_TIME 1)
|
|
endif()
|
|
if(APPLE OR
|
|
CYGWIN)
|
|
set(HAVE_MEMRCHR 0)
|
|
else()
|
|
set(HAVE_MEMRCHR 1)
|
|
endif()
|
|
set(HAVE_NETDB_H 1)
|
|
if(ANDROID)
|
|
set(HAVE_NETINET_IN6_H 1)
|
|
else()
|
|
set(HAVE_NETINET_IN6_H 0)
|
|
endif()
|
|
set(HAVE_NETINET_IN_H 1)
|
|
set(HAVE_NETINET_TCP_H 1)
|
|
set(HAVE_NETINET_UDP_H 1)
|
|
set(HAVE_NET_IF_H 1)
|
|
set(HAVE_OPENDIR 1)
|
|
set(HAVE_PIPE 1)
|
|
if(APPLE OR
|
|
CYGWIN)
|
|
set(HAVE_PIPE2 0)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
BSD OR CMAKE_SYSTEM_NAME MATCHES "BSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
|
set(HAVE_PIPE2 1)
|
|
endif()
|
|
set(HAVE_POLL 1)
|
|
set(HAVE_POLL_H 1)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
# Depends on C library.
|
|
else()
|
|
set(HAVE_POSIX_STRERROR_R 1)
|
|
endif()
|
|
set(HAVE_PWD_H 1)
|
|
set(HAVE_REALPATH 1)
|
|
set(HAVE_RECV 1)
|
|
set(HAVE_SA_FAMILY_T 1)
|
|
set(HAVE_SCHED_YIELD 1)
|
|
set(HAVE_SELECT 1)
|
|
set(HAVE_SEND 1)
|
|
if(APPLE OR
|
|
CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD")
|
|
set(HAVE_SENDMMSG 0)
|
|
else()
|
|
set(HAVE_SENDMMSG 1)
|
|
endif()
|
|
set(HAVE_SENDMSG 1)
|
|
set(HAVE_SETLOCALE 1)
|
|
set(HAVE_SETRLIMIT 1)
|
|
set(HAVE_SETSOCKOPT_SO_NONBLOCK 0)
|
|
set(HAVE_SIGACTION 1)
|
|
set(HAVE_SIGINTERRUPT 1)
|
|
set(HAVE_SIGNAL 1)
|
|
set(HAVE_SIGSETJMP 1)
|
|
set(HAVE_SOCKADDR_IN6_SIN6_ADDR 1)
|
|
set(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1)
|
|
set(HAVE_SOCKET 1)
|
|
set(HAVE_SOCKETPAIR 1)
|
|
set(HAVE_STDATOMIC_H 1)
|
|
set(HAVE_STDBOOL_H 1)
|
|
set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size()
|
|
set(HAVE_STDINT_H 1) # detected by CMake internally in check_type_size()
|
|
set(HAVE_STRCASECMP 1)
|
|
set(HAVE_STRCMPI 0)
|
|
set(HAVE_STRERROR_R 1)
|
|
set(HAVE_STRICMP 0)
|
|
set(HAVE_STRINGS_H 1)
|
|
if(_CURL_OLD_LINUX)
|
|
set(HAVE_STROPTS_H 1)
|
|
else()
|
|
set(HAVE_STROPTS_H 0) # glibc 2.30 or newer. https://sourceware.org/legacy-ml/libc-alpha/2019-08/msg00029.html
|
|
endif()
|
|
set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
|
|
set(HAVE_STRUCT_TIMEVAL 1)
|
|
if(ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
|
set(HAVE_SUSECONDS_T 1)
|
|
endif()
|
|
if(APPLE OR
|
|
CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
set(HAVE_SYS_EVENTFD_H 0)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
|
set(HAVE_SYS_EVENTFD_H 1)
|
|
endif()
|
|
if(CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
set(HAVE_SYS_FILIO_H 0)
|
|
else()
|
|
set(HAVE_SYS_FILIO_H 1)
|
|
endif()
|
|
set(HAVE_SYS_IOCTL_H 1)
|
|
set(HAVE_SYS_PARAM_H 1)
|
|
set(HAVE_SYS_POLL_H 1)
|
|
set(HAVE_SYS_RESOURCE_H 1)
|
|
set(HAVE_SYS_SELECT_H 1)
|
|
if(CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
set(HAVE_SYS_SOCKIO_H 0)
|
|
else()
|
|
set(HAVE_SYS_SOCKIO_H 1)
|
|
endif()
|
|
set(HAVE_SYS_TYPES_H 1)
|
|
set(HAVE_SYS_UN_H 1)
|
|
if(CYGWIN)
|
|
set(HAVE_SYS_UTIME_H 1)
|
|
else()
|
|
set(HAVE_SYS_UTIME_H 0)
|
|
endif()
|
|
set(HAVE_TERMIOS_H 1)
|
|
if(CYGWIN OR
|
|
CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
set(HAVE_TERMIO_H 1)
|
|
else()
|
|
set(HAVE_TERMIO_H 0)
|
|
endif()
|
|
set(HAVE_TIME_T_UNSIGNED 0)
|
|
set(HAVE_UNISTD_H 1)
|
|
set(HAVE_UTIME 1)
|
|
set(HAVE_UTIMES 1)
|
|
set(HAVE_UTIME_H 1)
|
|
set(HAVE_WRITABLE_ARGV 1)
|
|
set(STDC_HEADERS 1)
|
|
set(USE_UNIX_SOCKETS 1)
|