diff --git a/CMakeLists.txt b/CMakeLists.txt index d3ed0a2cd..b3c99edbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,19 +303,24 @@ if(WITH_NETWORK_BACKEND) option(WITH_NETWORK_GET_BUFFER "Enable experimental zero-copy transfers" OFF) if (WITH_NETWORK_GET_BUFFER) include(CheckCSourceCompiles) - check_c_source_compiles("#include \nint main(void) { return O_TMPFILE; }" HAS_O_TMPFILE) + check_c_source_compiles("#define _GNU_SOURCE=1\n#include \nint main(void) { return O_TMPFILE; }" + HAS_O_TMPFILE) if (NOT HAS_O_TMPFILE) message(SEND_ERROR "Zero-copy requires the O_TMPFILE flag, which is not available on the system.") endif() endif() - check_c_source_compiles("#include \nint main(void) { return eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); }" WITH_NETWORK_EVENTFD) - endif() + check_c_source_compiles("#include \nint main(void) { return eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); }" + WITH_NETWORK_EVENTFD) + if (NOT WITH_NETWORK_EVENTFD) + check_c_source_compiles("#define _GNU_SOURCE=1\n#include \n#include \nint main(void) { int fd[2]; return pipe2(fd, O_CLOEXEC | O_NONBLOCK); }" + HAS_PIPE2) + endif() - if(NOT WIN32) - include(CheckCSourceCompiles) - check_c_source_compiles("#include \n#include \nint main(void) { int fd[2]; return pipe2(fd, O_CLOEXEC | O_NONBLOCK); }" HAS_PIPE2) + if (WITH_NETWORK_GET_BUFFER OR HAS_PIPE2) + add_definitions(-D_GNU_SOURCE=1) + endif() endif() list(APPEND LIBIIO_CFILES network.c)