mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-31 00:03:08 +03:00
cmake: optimize non-blocking tests on WIN32/non-WIN32
Skip testing unixy methods on Windows and vice versa. I continue to assume that CMake doesn't define `WIN32` with Cygwin (as Cygwin doesn't define `_WIN32`/`WIN32` for C), though I haven't tested this. Closes #970
This commit is contained in:
@ -27,7 +27,8 @@ include(CheckCSourceCompiles)
|
|||||||
macro(check_nonblocking_socket_support)
|
macro(check_nonblocking_socket_support)
|
||||||
# There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
|
# There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
|
||||||
# O_NONBLOCK define is found but does not work.
|
# O_NONBLOCK define is found but does not work.
|
||||||
check_c_source_compiles("
|
if(NOT WIN32)
|
||||||
|
check_c_source_compiles("
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -52,10 +53,12 @@ int main(void)
|
|||||||
int socket = 0;
|
int socket = 0;
|
||||||
(void)fcntl(socket, F_SETFL, O_NONBLOCK);
|
(void)fcntl(socket, F_SETFL, O_NONBLOCK);
|
||||||
}"
|
}"
|
||||||
HAVE_O_NONBLOCK)
|
HAVE_O_NONBLOCK)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_O_NONBLOCK)
|
if(NOT HAVE_O_NONBLOCK)
|
||||||
check_c_source_compiles("/* FIONBIO test (old-style unix) */
|
if(NOT WIN32)
|
||||||
|
check_c_source_compiles("/* FIONBIO test (old-style unix) */
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stropts.h>
|
#include <stropts.h>
|
||||||
|
|
||||||
@ -65,10 +68,12 @@ int main(void)
|
|||||||
int flags = 0;
|
int flags = 0;
|
||||||
(void)ioctl(socket, FIONBIO, &flags);
|
(void)ioctl(socket, FIONBIO, &flags);
|
||||||
}"
|
}"
|
||||||
HAVE_FIONBIO)
|
HAVE_FIONBIO)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_FIONBIO)
|
if(NOT HAVE_FIONBIO)
|
||||||
check_c_source_compiles("/* ioctlsocket test (Windows) */
|
if(WIN32)
|
||||||
|
check_c_source_compiles("/* ioctlsocket test (Windows) */
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@ -82,7 +87,8 @@ int main(void)
|
|||||||
unsigned long flags = 0;
|
unsigned long flags = 0;
|
||||||
(void)ioctlsocket(sd, FIONBIO, &flags);
|
(void)ioctlsocket(sd, FIONBIO, &flags);
|
||||||
}"
|
}"
|
||||||
HAVE_IOCTLSOCKET)
|
HAVE_IOCTLSOCKET)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_IOCTLSOCKET)
|
if(NOT HAVE_IOCTLSOCKET)
|
||||||
check_c_source_compiles("/* IoctlSocket test (Amiga?) */
|
check_c_source_compiles("/* IoctlSocket test (Amiga?) */
|
||||||
@ -93,7 +99,7 @@ int main(void)
|
|||||||
int socket = 0;
|
int socket = 0;
|
||||||
(void)IoctlSocket(socket, FIONBIO, (long)1);
|
(void)IoctlSocket(socket, FIONBIO, (long)1);
|
||||||
}"
|
}"
|
||||||
HAVE_IOCTLSOCKET_CASE)
|
HAVE_IOCTLSOCKET_CASE)
|
||||||
|
|
||||||
if(NOT HAVE_IOCTLSOCKET_CASE)
|
if(NOT HAVE_IOCTLSOCKET_CASE)
|
||||||
check_c_source_compiles("/* SO_NONBLOCK test (BeOS) */
|
check_c_source_compiles("/* SO_NONBLOCK test (BeOS) */
|
||||||
@ -105,7 +111,7 @@ int main(void)
|
|||||||
int socket = 0;
|
int socket = 0;
|
||||||
(void)setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
|
(void)setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
|
||||||
}"
|
}"
|
||||||
HAVE_SO_NONBLOCK)
|
HAVE_SO_NONBLOCK)
|
||||||
|
|
||||||
if(NOT HAVE_SO_NONBLOCK)
|
if(NOT HAVE_SO_NONBLOCK)
|
||||||
# No non-blocking socket method found
|
# No non-blocking socket method found
|
||||||
|
Reference in New Issue
Block a user