How to check for accept4 using CMake
cmake, function, macros
Solution
Sure, 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 cleanup after the check.
Problem
I am checking for accept4 on Linux like this: ``` check_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4) ``` However, accept4 is only defined if _GNU_SOURCE is defined beforehand. How can I force the checker to defined _GNU_SOURCE before the check?