$NetBSD: patch-CMakeLists.txt,v 1.2 2021/06/10 12:26:26 nia Exp $ Fix detection of dlopen https://github.com/pocl/pocl/pull/950 --- CMakeLists.txt.orig 2021-05-19 08:12:19.000000000 +0000 +++ CMakeLists.txt @@ -787,9 +787,7 @@ elseif(UNIX) find_library(DL_LIB "dl") find_file(DL_H "dlfcn.h") - if(DL_LIB AND DL_H) - message(STATUS "libdl found") - + if(DL_H) get_filename_component(DL_H_INCLUDE_DIR "${DL_H}" DIRECTORY) string(FIND "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" "${DL_H_INCLUDE_DIR}" LTPOSITION) # include the directory of dlfcn.h, if its not in the default system include dirs @@ -797,9 +795,11 @@ elseif(UNIX) if((LTPOSITION LESS "0") AND (NOT CMAKE_CROSSCOMPILING)) include_directories("${DL_H_INCLUDE_DIR}") endif() - set(HAVE_LIBDL ON CACHE BOOL "dlopen" FORCE) - else() - message(FATAL_ERROR "Could not find DL library!") + set(HAVE_DLFCN_H ON) + endif() + + if(NOT DL_LIB) + set(DL_LIB "") endif() else()