How to check accept4 with CMake

I test accept4 on Linux as follows:

check_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4) 

However, accept4 is only defined if _GNU_SOURCE is predefined. How can I get the checker to determine _GNU_SOURCE before checking?

+4
source share
1 answer

Of course, use list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) before calling check_symbol_exists() and list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) to clear after checking.

+3
source

Source: https://habr.com/ru/post/1440460/


All Articles