From 79b4ddc27d1bb7a9674074090b66aa2e4bea225a Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 21 Jul 2025 16:54:27 +1000 Subject: [PATCH] Fix CMake script for NetBSD and OpenBSD. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aa61ac8..2929fd48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -450,7 +450,12 @@ endif() set(COMMON_LINK_LIBRARIES) if (UNIX) - list(APPEND COMMON_LINK_LIBRARIES dl) # For dlopen(), etc. Most compilers will link to this by default, but some may not. + # Not all platforms actually use a separate "dl" library, notably NetBSD and OpenBSD. + find_library(LIB_DL "dl") + if(LIB_DL) + list(APPEND COMMON_LINK_LIBRARIES dl) # For dlopen(), etc. Most compilers will link to this by default, but some may not. + endif() + list(APPEND COMMON_LINK_LIBRARIES pthread) # Some compilers will not link to pthread by default so list it here just in case. list(APPEND COMMON_LINK_LIBRARIES m)