Add Sendfile checks for cmake
This commit is contained in:
parent
21915eb92c
commit
199c94e7db
|
@ -42,6 +42,7 @@ include (CheckFunctionExists)
|
|||
include (CheckPrototypeDefinition_fixed)
|
||||
include (CheckTypeSize)
|
||||
include (CheckStructHasMember)
|
||||
include (CheckSendfile)
|
||||
|
||||
# Configuration options
|
||||
mark_as_advanced(FORCE ZM_EXTRA_LIBS ZM_MYSQL_ENGINE ZM_NO_MMAP CMAKE_INSTALL_FULL_BINDIR ZM_PERL_SUBPREFIX ZM_PERL_USE_PATH ZM_TARGET_DISTRO ZM_CONFIG_DIR)
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
# Check whether sendfile() is supported and what prototype it has
|
||||
include(CheckCSourceCompiles)
|
||||
if (UNIX OR MINGW)
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS -Werror-implicit-function-declaration)
|
||||
endif()
|
||||
check_c_source_compiles("#include <sys/sendfile.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
sendfile(1, 1, NULL, 0);
|
||||
return 0;
|
||||
}" HAVE_SENDFILE4_SUPPORT)
|
||||
if(HAVE_SENDFILE4_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE4_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: Linux/Solaris sendfile()")
|
||||
return()
|
||||
endif()
|
||||
find_library(SENDFILE_LIBRARIES NAMES sendfile)
|
||||
if(SENDFILE_LIBRARIES)
|
||||
include(CheckLibraryExists)
|
||||
check_library_exists(sendfile sendfile ${SENDFILE_LIBRARIES} HAVE_SENDFILE4_SUPPORT)
|
||||
if(HAVE_SENDFILE4_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE4_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: Solaris sendfile()")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
set(SENDFILE_LIBRARIES "")
|
||||
check_c_source_compiles("#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
sendfile(1, 1, 0, 0, NULL, NULL, 0);
|
||||
return 0;
|
||||
}" HAVE_SENDFILE7_SUPPORT)
|
||||
if(HAVE_SENDFILE7_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE7_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: FreeBSD sendfile()")
|
||||
return()
|
||||
endif()
|
||||
check_c_source_compiles("#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/uio.h>
|
||||
int main()
|
||||
{
|
||||
sendfile(1, 1, 0, NULL, NULL, 0);
|
||||
return 0;
|
||||
}" HAVE_SENDFILE6_SUPPORT)
|
||||
if(HAVE_SENDFILE6_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE6_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: MacOS sendfile()")
|
||||
return()
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue