CMake: Improve handling of dl.

This commit is contained in:
David Reid
2025-07-15 08:12:36 +10:00
parent a4072246c5
commit 51715474d7
+5 -3
View File
@@ -457,10 +457,12 @@ endif()
set(COMMON_LINK_LIBRARIES) set(COMMON_LINK_LIBRARIES)
if (UNIX) if (UNIX)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "NetBSD") # Not all platforms actually use a separate "dl" library, notably NetBSD and OpenBSD.
list(APPEND COMMON_LINK_LIBRARIES dl) # For dlopen(), etc. Most compilers will link to this by default, but some may not. 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() 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 pthread) # Some compilers will not link to pthread by default so list it here just in case.
list(APPEND COMMON_LINK_LIBRARIES m) list(APPEND COMMON_LINK_LIBRARIES m)