--- crt/aws-c-common/CMakeLists.txt.orig	2024-06-07 16:11:42 UTC
+++ crt/aws-c-common/CMakeLists.txt
@@ -115,6 +115,9 @@ else ()
     elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
         list(APPEND PLATFORM_LIBS dl m thr execinfo)
         list (APPEND AWS_COMMON_OS_SRC "source/platform_fallback_stubs/system_info.c")
+    elseif(CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
+        list(APPEND PLATFORM_LIBS dl m thr execinfo)
+        list (APPEND AWS_COMMON_OS_SRC "source/platform_fallback_stubs/system_info.c")
     elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
         list(APPEND PLATFORM_LIBS dl m Threads::Threads execinfo)
         list (APPEND AWS_COMMON_OS_SRC "source/platform_fallback_stubs/system_info.c")
@@ -194,7 +197,7 @@ aws_check_headers(${PROJECT_NAME} ${AWS_COMMON_HEADERS
 
 #apple source already includes the definitions we want, and setting this posix source
 #version causes it to revert to an older version. So don't turn it on there, we don't need it.
-if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD|OpenBSD)
+if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES MidnightBSD|FreeBSD|OpenBSD)
     #this only gets applied to aws-c-common (not its consumers).
     target_compile_definitions(${PROJECT_NAME} PRIVATE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500)
 endif()
