build: Fix check dlopen

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
main
Jianhui Zhao 2020-04-05 19:55:48 +08:00
parent b4adc20935
commit abaedeeac2
2 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.8)
project(libuhttpd C) project(libuhttpd C)
INCLUDE(CheckLibraryExists)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
add_subdirectory(src) add_subdirectory(src)

View File

@ -8,15 +8,14 @@ set(UHTTPD_VERSION_PATCH 2)
# Check the third party Libraries # Check the third party Libraries
find_package(Libev REQUIRED) find_package(Libev REQUIRED)
find_library(LIBDL dl)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/buffer ${CMAKE_CURRENT_BINARY_DIR} ${LIBEV_INCLUDE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/buffer ${CMAKE_CURRENT_BINARY_DIR} ${LIBEV_INCLUDE_DIR})
set(EXTRA_LIBS ${LIBEV_LIBRARY} m) set(EXTRA_LIBS ${LIBEV_LIBRARY} m)
if(NOT ${LIBDL} STREQUAL "LIBDL-NOTFOUND") check_library_exists(dl dlopen "" HAVE_DLOPEN)
message(STATUS "Found Libdl: ${LIBDL}") if(HAVE_DLOPEN)
list(APPEND EXTRA_LIBS ${LIBDL}) list(APPEND EXTRA_LIBS dl)
add_definitions(-DHAVE_DLOPEN) add_definitions(-DHAVE_DLOPEN)
endif() endif()
@ -108,7 +107,7 @@ target_link_libraries(uhttpd_s ${EXTRA_LIBS})
# configure a header file to pass some of the CMake settings to the source code # configure a header file to pass some of the CMake settings to the source code
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
if(NOT ${LIBDL} STREQUAL "LIBDL-NOTFOUND") if(HAVE_DLOPEN)
add_subdirectory(plugins) add_subdirectory(plugins)
endif() endif()