]> granicus.if.org Git - libexpat/commitdiff
CMake: properly search and announce libbsd support
authorRolf Eike Beer <eb@emlix.com>
Mon, 7 Aug 2017 08:29:42 +0000 (10:29 +0200)
committerRolf Eike Beer <eike@sf-mail.de>
Mon, 7 Aug 2017 18:16:45 +0000 (20:16 +0200)
expat/CMakeLists.txt
expat/ConfigureChecks.cmake
expat/expat_config.h.cmake

index 271ccf3bfa8c97fea63c497fa2e128de9f00517f..de31d4584a4b5a63d37e6f7bea8371b420c87ee7 100644 (file)
@@ -18,6 +18,15 @@ option(BUILD_doc "build man page for xmlwf" ON)
 option(USE_libbsd "utilize libbsd (for arc4random_buf)" OFF)\r
 option(INSTALL "install expat files in cmake install target" ON)\r
 \r
+if(USE_libbsd)\r
+    find_library(LIB_BSD NAMES bsd)\r
+    if(NOT LIB_BSD)\r
+        message(FATAL_ERROR "USE_libbsd option is enabled, but libbsd was not found")\r
+    else()\r
+        set(HAVE_LIBBSD TRUE)\r
+    endif()\r
+endif()\r
+\r
 # configuration options\r
 set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point")\r
 option(XML_DTD "Define to make parameter entity parsing functionality available" ON)\r
@@ -86,7 +95,7 @@ endif(BUILD_shared)
 \r
 add_library(expat ${_SHARED} ${expat_SRCS})\r
 if(USE_libbsd)\r
-    target_link_libraries(expat bsd)\r
+    target_link_libraries(expat ${LIB_BSD})\r
 endif()\r
 \r
 set(LIBCURRENT 7)   # sync\r
index 7d44ec1aaf2dea166e360d28cc1391157b8bdcd0..d97b397227b6edce7205c1e2d5cb56f6d42368ae 100644 (file)
@@ -25,7 +25,7 @@ check_function_exists("mmap" HAVE_MMAP)
 check_function_exists("getrandom" HAVE_GETRANDOM)\r
 \r
 if(USE_libbsd)\r
-    set(CMAKE_REQUIRED_LIBRARIES "bsd")\r
+    set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")\r
 endif()\r
 check_function_exists("arc4random_buf" HAVE_ARC4RANDOM_BUF)\r
 if(NOT HAVE_ARC4RANDOM_BUF)\r
index 864c7a690e1765d4b9ba6128b1608ccc2e822b7b..a93c97119ede04000661ca79a4d8b30ad684747d 100644 (file)
@@ -27,6 +27,9 @@
 /* Define to 1 if you have the <inttypes.h> header file. */\r
 #cmakedefine HAVE_INTTYPES_H\r
 \r
+/* Define to 1 if you have the `bsd' library (-lbsd). */\r
+#cmakedefine HAVE_LIBBSD\r
+\r
 /* Define to 1 if you have the `memmove' function. */\r
 #cmakedefine HAVE_MEMMOVE\r
 \r