From 93209958cfbf8805debc0a9a233553f75977f6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 12 Jun 2024 18:49:21 +0200 Subject: [PATCH] GraphBLAS: Check for ability to link with libdl. On some platforms (like NetBSD), `dlopen` and similar functions are not in a library. They can be used in any dynamically linked program instead: https://man.netbsd.org/dlopen.3 Use a feature test during configuration to check whether linking to libdl is necessary (or possible). --- GraphBLAS/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GraphBLAS/CMakeLists.txt b/GraphBLAS/CMakeLists.txt index 8677da436..68811a408 100644 --- a/GraphBLAS/CMakeLists.txt +++ b/GraphBLAS/CMakeLists.txt @@ -409,7 +409,9 @@ if ( NOT NO_LIBM ) endif ( ) # libdl -if ( NOT WIN32 ) +include ( CheckLibraryExists ) +check_library_exists ( "dl" "dlopen" "${CMAKE_LIBRARY_PATH}" HAVE_DL ) +if ( HAVE_DL AND NOT WIN32 ) if ( BUILD_SHARED_LIBS ) target_link_libraries ( GraphBLAS PRIVATE dl ) endif ( )