diff --git a/CMakeLists.txt b/CMakeLists.txt
index c27304ee23a001d51900fc1b002f33bc676f736e..3878adf14d7372cfcc290314de6d48312fb616f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,3 +63,6 @@ add_library(xpdevplus STATIC ${SOURCE})
 target_link_libraries(xpdevplus ciolib comio encode hash uifc xpdev)
 target_include_directories(xpdevplus PUBLIC ${XPDevPlus_BINARY_DIR})
 target_compile_options(xpdevplus PUBLIC "SHELL:-include xpdevplus.h")
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+target_compile_options(xpdevplus PUBLIC POSIX_C_SOURCE 200809L _DEFAULT_SOURCE _BSD_SOURCE SPEED_MACROS_ONLY _GNU_SOURCE _FILE_OFFSET_BITS 64)
+endif()
diff --git a/xpdevplus.h.in b/xpdevplus.h.in
index 0afdeebf49cf98cc57744f6080d6fb8adbc2c15c..f52a451bac37d05628c0378d2980d86707b953a0 100644
--- a/xpdevplus.h.in
+++ b/xpdevplus.h.in
@@ -1,17 +1,6 @@
 #ifndef XPDEV_PLUS_H
 #define XPDEV_PLUS_H
 
-#ifdef __linux__
-#define POSIX_C_SOURCE 200809L
-#define _DEFAULT_SOURCE
-#define _BSD_SOURCE
-#define SPEED_MACROS_ONLY 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE 
-#endif
-#define _FILE_OFFSET_BITS 64
-#endif
-
 #cmakedefine WITH_SDL
 #cmakedefine N_CURSES_LIB
 #cmakedefine HAS_INTTYPES_H