1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

cmake: check if _GNU_SOURCE is already defined

This commit is contained in:
Pavel Otchertsov 2021-03-25 11:09:13 +03:00 committed by Andy Green
parent f84b90ba03
commit ebe44543ee
2 changed files with 13 additions and 2 deletions

View file

@ -658,7 +658,10 @@ if ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR
endif()
if (LWS_HAVE_PTHREAD_H AND NOT LWS_PLAT_FREERTOS)
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE
CHECK_C_SOURCE_COMPILES("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
int main(void) {
pthread_t th = 0;

View file

@ -103,7 +103,15 @@ endif()
# ideally we want to use pipe2()
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE\n#include <unistd.h>\nint main(void) {int fd[2];\n return pipe2(fd, 0);\n}\n" LWS_HAVE_PIPE2)
CHECK_C_SOURCE_COMPILES("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <unistd.h>
int main(void) {
int fd[2];
return pipe2(fd, 0);
}" LWS_HAVE_PIPE2)
# tcp keepalive needs this on linux to work practically... but it only exists
# after kernel 2.6.37