From: Rolf Eike Beer Date: Mon, 7 Aug 2017 08:29:42 +0000 (+0200) Subject: CMake: properly search and announce libbsd support X-Git-Tag: R_2_2_4~20^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27203d8df9431437690ddeb704a0f3a2eddeb954;p=libexpat CMake: properly search and announce libbsd support --- diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 271ccf3b..de31d458 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -18,6 +18,15 @@ option(BUILD_doc "build man page for xmlwf" ON) option(USE_libbsd "utilize libbsd (for arc4random_buf)" OFF) option(INSTALL "install expat files in cmake install target" ON) +if(USE_libbsd) + find_library(LIB_BSD NAMES bsd) + if(NOT LIB_BSD) + message(FATAL_ERROR "USE_libbsd option is enabled, but libbsd was not found") + else() + set(HAVE_LIBBSD TRUE) + endif() +endif() + # configuration options set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point") option(XML_DTD "Define to make parameter entity parsing functionality available" ON) @@ -86,7 +95,7 @@ endif(BUILD_shared) add_library(expat ${_SHARED} ${expat_SRCS}) if(USE_libbsd) - target_link_libraries(expat bsd) + target_link_libraries(expat ${LIB_BSD}) endif() set(LIBCURRENT 7) # sync diff --git a/expat/ConfigureChecks.cmake b/expat/ConfigureChecks.cmake index 7d44ec1a..d97b3972 100644 --- a/expat/ConfigureChecks.cmake +++ b/expat/ConfigureChecks.cmake @@ -25,7 +25,7 @@ check_function_exists("mmap" HAVE_MMAP) check_function_exists("getrandom" HAVE_GETRANDOM) if(USE_libbsd) - set(CMAKE_REQUIRED_LIBRARIES "bsd") + set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}") endif() check_function_exists("arc4random_buf" HAVE_ARC4RANDOM_BUF) if(NOT HAVE_ARC4RANDOM_BUF) diff --git a/expat/expat_config.h.cmake b/expat/expat_config.h.cmake index 864c7a69..a93c9711 100644 --- a/expat/expat_config.h.cmake +++ b/expat/expat_config.h.cmake @@ -27,6 +27,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H +/* Define to 1 if you have the `bsd' library (-lbsd). */ +#cmakedefine HAVE_LIBBSD + /* Define to 1 if you have the `memmove' function. */ #cmakedefine HAVE_MEMMOVE