From 6a19b515166f88c6909cac99e67a2a62239e4395 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Mon, 4 Jan 2016 00:47:12 +0100
Subject: Fix build of tests under BSD
---
CMakeLists.txt | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f430c2e..4635d28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,17 +8,32 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
# Dependencies
+set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+include (AddThreads)
+
find_package (PkgConfig REQUIRED)
pkg_check_modules (libssl REQUIRED libssl libcrypto)
-set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
-include (AddThreads)
+if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
+ include_directories (/usr/local/include)
+ link_directories (/usr/local/lib)
+ # Our POSIX version macros make these undefined
+ add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
+endif ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
-# -lrt is only for glibc < 2.17
-set (common_libraries ${libssl_LIBRARIES} rt)
+set (common_libraries ${libssl_LIBRARIES})
include_directories (${libssl_INCLUDE_DIRS})
link_directories (${libssl_LIBRARY_DIRS})
+# -lrt is only for glibc < 2.17
+# -liconv may or may not be a part of libc
+foreach (extra iconv rt)
+ find_library (extra_lib_${extra} ${extra})
+ if (extra_lib_${extra})
+ list (APPEND common_libraries ${extra})
+ endif (extra_lib_${extra})
+endforeach (extra)
+
# Generate a configuration file
# TODO: actualy use the configuration file for something; so far we allow
# for direct inclusion without running this CMakeLists.txt
--
cgit v1.2.3-70-g09d2