build UPDATE define global macros
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2367994..4a6f977 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,8 +75,8 @@
     set(C_STANDARD_REQUIRED ON)
     set(CMAKE_C_FLAGS "/Zc:preprocessor /W3 /wd4711 /w14013 /utf-8 ${CMAKE_C_FLAGS}")
 else()
-    # global C flags
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -std=c11")
+    # global C flags (POSIX source because of pthread_rwlock_t)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -std=c11 -D_POSIX_C_SOURCE=200809L")
 endif()
 
 include_directories(${PROJECT_BINARY_DIR}/libyang ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/plugins_exts)
diff --git a/compat/compat.c b/compat/compat.c
index ea8a618..30343a5 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -11,7 +11,9 @@
  *
  *     https://opensource.org/licenses/BSD-3-Clause
  */
-#define _POSIX_C_SOURCE 200809L /* fdopen, _POSIX_PATH_MAX, strdup */
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200809L /* fdopen, _POSIX_PATH_MAX, strdup */
+#endif
 #define _ISOC99_SOURCE /* vsnprintf */
 
 #include "compat.h"
diff --git a/src/in.c b/src/in.c
index 38b42a8..5d20a93 100644
--- a/src/in.c
+++ b/src/in.c
@@ -13,7 +13,6 @@
  */
 
 #define _GNU_SOURCE
-#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
 
 #include "in.h"
 #include "in_internal.h"
diff --git a/src/parser_common.c b/src/parser_common.c
index 9246e9f..809ec2a 100644
--- a/src/parser_common.c
+++ b/src/parser_common.c
@@ -13,7 +13,6 @@
  */
 
 #define _GNU_SOURCE
-#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
 
 #ifdef __APPLE__
 #define _DARWIN_C_SOURCE /* F_GETPATH */
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
index 251dd10..7f45a95 100644
--- a/tests/utests/utests.h
+++ b/tests/utests/utests.h
@@ -17,8 +17,6 @@
 #ifndef _UTESTS_H_
 #define _UTESTS_H_
 
-#define _POSIX_C_SOURCE 200809L /* strdup */
-
 #include <setjmp.h>
 #include <stdarg.h>
 #include <stddef.h>