3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-05-25 19:36:21 +00:00
yosys/cmake/FindDlfcn.cmake
2026-05-22 19:54:19 +02:00

27 lines
754 B
CMake

include(CMakePushCheckState)
include(CheckCXXSymbolExists)
include(FindPackageHandleStandardArgs)
if (MSVC)
set(Dlfcn_FOUND FALSE)
unset(Dlfcn_LIBRARIES CACHE)
elseif (WIN32 OR MSYS)
# Windows; dlopen is available via a polyfill `libs/dlfcn-win32`.
set(Dlfcn_LIBRARIES dlfcn)
else()
# Unix and Wasm; dlopen may or may not be available depending on platform.
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
check_cxx_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
cmake_pop_check_state()
if (HAVE_DLOPEN)
add_library(dlfcn INTERFACE)
target_link_libraries(dlfcn INTERFACE ${CMAKE_DL_LIBS})
set(Dlfcn_LIBRARIES dlfcn)
endif()
endif()
find_package_handle_standard_args(Dlfcn
REQUIRED_VARS Dlfcn_LIBRARIES
)