cmake: remove CheckFunctionExistsEx

`CheckFunctionExistsEx` is copied from the cmake modules before
3.1.2, which is the minimum required version of libevent.
The internal module `CheckFunctionExists`of cmake can completely
replace it.
This commit is contained in:
yuangongji 2020-03-16 18:57:54 +08:00 committed by Azat Khuzhin
parent 6d54be2cc0
commit 61c5c19bfd
3 changed files with 56 additions and 154 deletions

View File

@ -51,7 +51,6 @@ string(REGEX MATCH "SunOS" SOLARIS "${CMAKE_SYSTEM_NAME}")
include(CheckTypeSize)
include(CheckFunctionExistsEx)
include(CheckFileOffsetBits)
include(CheckFunctionExists)
include(CheckIncludeFile)
@ -452,62 +451,62 @@ CHECK_INCLUDE_FILE(sys/timerfd.h EVENT__HAVE_SYS_TIMERFD_H)
CHECK_INCLUDE_FILE(errno.h EVENT__HAVE_ERRNO_H)
CHECK_FUNCTION_EXISTS_EX(epoll_create EVENT__HAVE_EPOLL)
CHECK_FUNCTION_EXISTS_EX(epoll_ctl EVENT__HAVE_EPOLL_CTL)
CHECK_FUNCTION_EXISTS_EX(eventfd EVENT__HAVE_EVENTFD)
CHECK_FUNCTION_EXISTS(epoll_create EVENT__HAVE_EPOLL)
CHECK_FUNCTION_EXISTS(epoll_ctl EVENT__HAVE_EPOLL_CTL)
CHECK_FUNCTION_EXISTS(eventfd EVENT__HAVE_EVENTFD)
if(NOT EVENT__DISABLE_CLOCK_GETTIME)
CHECK_FUNCTION_EXISTS_EX(clock_gettime EVENT__HAVE_CLOCK_GETTIME)
CHECK_FUNCTION_EXISTS(clock_gettime EVENT__HAVE_CLOCK_GETTIME)
endif()
CHECK_FUNCTION_EXISTS_EX(fcntl EVENT__HAVE_FCNTL)
CHECK_FUNCTION_EXISTS_EX(getaddrinfo EVENT__HAVE_GETADDRINFO)
CHECK_FUNCTION_EXISTS_EX(getnameinfo EVENT__HAVE_GETNAMEINFO)
CHECK_FUNCTION_EXISTS_EX(gettimeofday EVENT__HAVE_GETTIMEOFDAY)
CHECK_FUNCTION_EXISTS_EX(getprotobynumber EVENT__HAVE_GETPROTOBYNUMBER)
CHECK_FUNCTION_EXISTS_EX(getservbyname EVENT__HAVE_GETSERVBYNAME)
CHECK_FUNCTION_EXISTS_EX(inet_ntop EVENT__HAVE_INET_NTOP)
CHECK_FUNCTION_EXISTS_EX(inet_pton EVENT__HAVE_INET_PTON)
CHECK_FUNCTION_EXISTS_EX(kqueue EVENT__HAVE_KQUEUE)
CHECK_FUNCTION_EXISTS_EX(mmap EVENT__HAVE_MMAP)
CHECK_FUNCTION_EXISTS_EX(pipe EVENT__HAVE_PIPE)
CHECK_FUNCTION_EXISTS_EX(pipe2 EVENT__HAVE_PIPE2)
CHECK_FUNCTION_EXISTS_EX(poll EVENT__HAVE_POLL)
CHECK_FUNCTION_EXISTS_EX(port_create EVENT__HAVE_PORT_CREATE)
CHECK_FUNCTION_EXISTS_EX(sendfile EVENT__HAVE_SENDFILE)
CHECK_FUNCTION_EXISTS_EX(sigaction EVENT__HAVE_SIGACTION)
CHECK_FUNCTION_EXISTS_EX(signal EVENT__HAVE_SIGNAL)
CHECK_FUNCTION_EXISTS_EX(strsignal EVENT__HAVE_STRSIGNAL)
CHECK_FUNCTION_EXISTS_EX(splice EVENT__HAVE_SPLICE)
CHECK_FUNCTION_EXISTS_EX(strlcpy EVENT__HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS_EX(strsep EVENT__HAVE_STRSEP)
CHECK_FUNCTION_EXISTS_EX(strtok_r EVENT__HAVE_STRTOK_R)
CHECK_FUNCTION_EXISTS_EX(strtoll EVENT__HAVE_STRTOLL)
CHECK_FUNCTION_EXISTS_EX(vasprintf EVENT__HAVE_VASPRINTF)
CHECK_FUNCTION_EXISTS_EX(sysctl EVENT__HAVE_SYSCTL)
CHECK_FUNCTION_EXISTS_EX(accept4 EVENT__HAVE_ACCEPT4)
CHECK_FUNCTION_EXISTS_EX(arc4random EVENT__HAVE_ARC4RANDOM)
CHECK_FUNCTION_EXISTS_EX(arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF)
CHECK_FUNCTION_EXISTS_EX(arc4random_addrandom EVENT__HAVE_ARC4RANDOM_ADDRANDOM)
CHECK_FUNCTION_EXISTS_EX(epoll_create1 EVENT__HAVE_EPOLL_CREATE1)
CHECK_FUNCTION_EXISTS_EX(getegid EVENT__HAVE_GETEGID)
CHECK_FUNCTION_EXISTS_EX(geteuid EVENT__HAVE_GETEUID)
CHECK_FUNCTION_EXISTS_EX(getifaddrs EVENT__HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS_EX(issetugid EVENT__HAVE_ISSETUGID)
CHECK_FUNCTION_EXISTS_EX(mach_absolute_time EVENT__HAVE_MACH_ABSOLUTE_TIME)
CHECK_FUNCTION_EXISTS_EX(nanosleep EVENT__HAVE_NANOSLEEP)
CHECK_FUNCTION_EXISTS_EX(usleep EVENT__HAVE_USLEEP)
CHECK_FUNCTION_EXISTS_EX(timeradd EVENT__HAVE_TIMERADD)
CHECK_FUNCTION_EXISTS_EX(timerclear EVENT__HAVE_TIMERCLEAR)
CHECK_FUNCTION_EXISTS_EX(timercmp EVENT__HAVE_TIMERCMP)
CHECK_FUNCTION_EXISTS_EX(timerfd_create EVENT__HAVE_TIMERFD_CREATE)
CHECK_FUNCTION_EXISTS_EX(timerisset EVENT__HAVE_TIMERISSET)
CHECK_FUNCTION_EXISTS_EX(putenv EVENT__HAVE_PUTENV)
CHECK_FUNCTION_EXISTS_EX(setenv EVENT__HAVE_SETENV)
CHECK_FUNCTION_EXISTS_EX(setrlimit EVENT__HAVE_SETRLIMIT)
CHECK_FUNCTION_EXISTS_EX(umask EVENT__HAVE_UMASK)
CHECK_FUNCTION_EXISTS_EX(unsetenv EVENT__HAVE_UNSETENV)
CHECK_FUNCTION_EXISTS(fcntl EVENT__HAVE_FCNTL)
CHECK_FUNCTION_EXISTS(getaddrinfo EVENT__HAVE_GETADDRINFO)
CHECK_FUNCTION_EXISTS(getnameinfo EVENT__HAVE_GETNAMEINFO)
CHECK_FUNCTION_EXISTS(gettimeofday EVENT__HAVE_GETTIMEOFDAY)
CHECK_FUNCTION_EXISTS(getprotobynumber EVENT__HAVE_GETPROTOBYNUMBER)
CHECK_FUNCTION_EXISTS(getservbyname EVENT__HAVE_GETSERVBYNAME)
CHECK_FUNCTION_EXISTS(inet_ntop EVENT__HAVE_INET_NTOP)
CHECK_FUNCTION_EXISTS(inet_pton EVENT__HAVE_INET_PTON)
CHECK_FUNCTION_EXISTS(kqueue EVENT__HAVE_KQUEUE)
CHECK_FUNCTION_EXISTS(mmap EVENT__HAVE_MMAP)
CHECK_FUNCTION_EXISTS(pipe EVENT__HAVE_PIPE)
CHECK_FUNCTION_EXISTS(pipe2 EVENT__HAVE_PIPE2)
CHECK_FUNCTION_EXISTS(poll EVENT__HAVE_POLL)
CHECK_FUNCTION_EXISTS(port_create EVENT__HAVE_PORT_CREATE)
CHECK_FUNCTION_EXISTS(sendfile EVENT__HAVE_SENDFILE)
CHECK_FUNCTION_EXISTS(sigaction EVENT__HAVE_SIGACTION)
CHECK_FUNCTION_EXISTS(signal EVENT__HAVE_SIGNAL)
CHECK_FUNCTION_EXISTS(strsignal EVENT__HAVE_STRSIGNAL)
CHECK_FUNCTION_EXISTS(splice EVENT__HAVE_SPLICE)
CHECK_FUNCTION_EXISTS(strlcpy EVENT__HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS(strsep EVENT__HAVE_STRSEP)
CHECK_FUNCTION_EXISTS(strtok_r EVENT__HAVE_STRTOK_R)
CHECK_FUNCTION_EXISTS(strtoll EVENT__HAVE_STRTOLL)
CHECK_FUNCTION_EXISTS(vasprintf EVENT__HAVE_VASPRINTF)
CHECK_FUNCTION_EXISTS(sysctl EVENT__HAVE_SYSCTL)
CHECK_FUNCTION_EXISTS(accept4 EVENT__HAVE_ACCEPT4)
CHECK_FUNCTION_EXISTS(arc4random EVENT__HAVE_ARC4RANDOM)
CHECK_FUNCTION_EXISTS(arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF)
CHECK_FUNCTION_EXISTS(arc4random_addrandom EVENT__HAVE_ARC4RANDOM_ADDRANDOM)
CHECK_FUNCTION_EXISTS(epoll_create1 EVENT__HAVE_EPOLL_CREATE1)
CHECK_FUNCTION_EXISTS(getegid EVENT__HAVE_GETEGID)
CHECK_FUNCTION_EXISTS(geteuid EVENT__HAVE_GETEUID)
CHECK_FUNCTION_EXISTS(getifaddrs EVENT__HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS(issetugid EVENT__HAVE_ISSETUGID)
CHECK_FUNCTION_EXISTS(mach_absolute_time EVENT__HAVE_MACH_ABSOLUTE_TIME)
CHECK_FUNCTION_EXISTS(nanosleep EVENT__HAVE_NANOSLEEP)
CHECK_FUNCTION_EXISTS(usleep EVENT__HAVE_USLEEP)
CHECK_FUNCTION_EXISTS(timeradd EVENT__HAVE_TIMERADD)
CHECK_FUNCTION_EXISTS(timerclear EVENT__HAVE_TIMERCLEAR)
CHECK_FUNCTION_EXISTS(timercmp EVENT__HAVE_TIMERCMP)
CHECK_FUNCTION_EXISTS(timerfd_create EVENT__HAVE_TIMERFD_CREATE)
CHECK_FUNCTION_EXISTS(timerisset EVENT__HAVE_TIMERISSET)
CHECK_FUNCTION_EXISTS(putenv EVENT__HAVE_PUTENV)
CHECK_FUNCTION_EXISTS(setenv EVENT__HAVE_SETENV)
CHECK_FUNCTION_EXISTS(setrlimit EVENT__HAVE_SETRLIMIT)
CHECK_FUNCTION_EXISTS(umask EVENT__HAVE_UMASK)
CHECK_FUNCTION_EXISTS(unsetenv EVENT__HAVE_UNSETENV)
# Get the gethostbyname_r prototype.
CHECK_FUNCTION_EXISTS_EX(gethostbyname_r EVENT__HAVE_GETHOSTBYNAME_R)
CHECK_FUNCTION_EXISTS(gethostbyname_r EVENT__HAVE_GETHOSTBYNAME_R)
if(EVENT__HAVE_GETHOSTBYNAME_R)
CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
@ -534,13 +533,13 @@ if(HAVE_PORT_H AND HAVE_PORT_CREATE)
endif()
if(NOT WIN32)
CHECK_FUNCTION_EXISTS_EX(select EVENT__HAVE_SELECT)
CHECK_FUNCTION_EXISTS(select EVENT__HAVE_SELECT)
endif()
if(WIN32)
CHECK_FUNCTION_EXISTS_EX(_gmtime64_s EVENT__HAVE__GMTIME64_S)
CHECK_FUNCTION_EXISTS(_gmtime64_s EVENT__HAVE__GMTIME64_S)
if (NOT EVENT__HAVE__GMTIME64_S)
CHECK_FUNCTION_EXISTS_EX(_gmtime64 EVENT__HAVE__GMTIME64)
CHECK_FUNCTION_EXISTS(_gmtime64 EVENT__HAVE__GMTIME64)
endif()
endif()
@ -583,7 +582,7 @@ CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH)
CHECK_CONST_EXISTS(CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN)
CHECK_CONST_EXISTS(KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND)
CHECK_SYMBOL_EXISTS(F_SETFD fcntl.h EVENT__HAVE_SETFD)
CHECK_FUNCTION_EXISTS_EX(getrandom EVENT__HAVE_GETRANDOM)
CHECK_FUNCTION_EXISTS(getrandom EVENT__HAVE_GETRANDOM)
CHECK_TYPE_SIZE(fd_mask EVENT__HAVE_FD_MASK)

View File

@ -1,28 +0,0 @@
#ifdef CHECK_FUNCTION_EXISTS
#ifdef __cplusplus
extern "C"
#endif
char
CHECK_FUNCTION_EXISTS(void);
#ifdef __CLASSIC_C__
int main()
{
int ac;
char* av[];
#else
int main(int ac, char* av[])
{
#endif
CHECK_FUNCTION_EXISTS();
if (ac > 1000) {
return *av[0];
}
return 0;
}
#else /* CHECK_FUNCTION_EXISTS */
#error "CHECK_FUNCTION_EXISTS has to specify the function"
#endif /* CHECK_FUNCTION_EXISTS */

View File

@ -1,69 +0,0 @@
# - Check if a C function can be linked
# CHECK_FUNCTION_EXISTS(<function> <variable>)
#
# Check that the <function> is provided by libraries on the system and
# store the result in a <variable>. This does not verify that any
# system header file declares the function, only that it can be found
# at link time (considure using CheckSymbolExists).
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2002-2011 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
MACRO(CHECK_FUNCTION_EXISTS_EX FUNCTION VARIABLE)
IF(${VARIABLE} MATCHES "^${VARIABLE}$")
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
MESSAGE(STATUS "Looking for ${FUNCTION}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ELSE(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
ENDIF(CMAKE_REQUIRED_LIBRARIES)
IF(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
ELSE(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES)
ENDIF(CMAKE_REQUIRED_INCLUDES)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/CheckFunctionExistsEx.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
"${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
MESSAGE(STATUS "Looking for ${FUNCTION} - found")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the function ${FUNCTION} exists passed with the following output:\n"
"${OUTPUT}\n\n")
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for ${FUNCTION} - not found")
SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the function ${FUNCTION} exists failed with the following output:\n"
"${OUTPUT}\n\n")
ENDIF(${VARIABLE})
ENDIF()
ENDMACRO(CHECK_FUNCTION_EXISTS_EX)