diff --git a/CMakeLists.txt b/CMakeLists.txt index e94757cdf..7966444be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 int main(void) { pthread_t th = 0; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 5494341ec..7f132c877 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -103,7 +103,15 @@ endif() # ideally we want to use pipe2() -CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE\n#include \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 + 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