--- CMakeLists.txt.orig	2020-01-07 14:53:40.785519000 -0500
+++ CMakeLists.txt	2020-01-07 14:53:50.814481000 -0500
@@ -588,7 +588,7 @@
     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD)
     if(ANDROID)
       set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m log)
-    elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD|DragonFly|OpenBSD|Haiku")
+    elseif(${CMAKE_SYSTEM_NAME} MATCHES "MidnightBSD|FreeBSD|NetBSD|DragonFly|OpenBSD|Haiku")
       set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m pthread)
     elseif(EMSCRIPTEN)
       # no need to link to system libs with emscripten
