Fix build of tests under BSD

This commit is contained in:
Přemysl Eric Janouch 2016-01-04 00:47:12 +01:00
parent 3f20b39b71
commit 6a19b51516
1 changed files with 20 additions and 5 deletions

View File

@ -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) endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
# Dependencies # Dependencies
find_package (PkgConfig REQUIRED)
pkg_check_modules (libssl REQUIRED libssl libcrypto)
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include (AddThreads) include (AddThreads)
# -lrt is only for glibc < 2.17 find_package (PkgConfig REQUIRED)
set (common_libraries ${libssl_LIBRARIES} rt) pkg_check_modules (libssl REQUIRED libssl libcrypto)
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")
set (common_libraries ${libssl_LIBRARIES})
include_directories (${libssl_INCLUDE_DIRS}) include_directories (${libssl_INCLUDE_DIRS})
link_directories (${libssl_LIBRARY_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 # Generate a configuration file
# TODO: actualy use the configuration file for something; so far we allow # TODO: actualy use the configuration file for something; so far we allow
# for direct inclusion without running this CMakeLists.txt # for direct inclusion without running this CMakeLists.txt