Fix OpenBSD build

This commit is contained in:
Přemysl Eric Janouch 2015-07-30 18:11:29 +02:00
parent 637a3d2bf7
commit cfc78ffdf0
2 changed files with 29 additions and 10 deletions

View File

@ -27,18 +27,31 @@ pkg_check_modules (libssl REQUIRED libssl libcrypto)
pkg_check_modules (ncursesw ncursesw)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# iconv() doesn't have to be present in libc
# FIXME: detect if we need the library independently on the platform
list (APPEND project_libraries iconv)
# Need this for SIGWINCH; our POSIX version macros make it undefined
add_definitions (-D__BSD_VISIBLE=1)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
# our POSIX version macros make it undefined
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# iconv may or may not be present in libc
find_library (iconv_LIBRARIES iconv)
if (iconv_LIBRARIES)
list (APPEND project_libraries ${iconv_LIBRARIES})
endif (iconv_LIBRARIES)
list (APPEND project_libraries ${libssl_LIBRARIES})
include_directories (${libssl_INCLUDE_DIRS})
link_directories (${libssl_LIBRARY_DIRS})
# -lpthread is only there for debugging (gdb & errno)
# -lrt is only for glibc < 2.17
list (APPEND project_libraries ${libssl_LIBRARIES} rt pthread)
include_directories (${libssl_INCLUDE_DIRS})
link_directories (${libssl_LIBRARY_DIRS})
foreach (extra rt pthread)
find_library (extra_lib ${extra})
if (extra_lib)
list (APPEND project_libraries ${extra})
endif (extra_lib)
endforeach (extra)
if (ncursesw_FOUND)
list (APPEND project_libraries ${ncursesw_LIBRARIES})
@ -53,7 +66,13 @@ endif (ncursesw_FOUND)
if ((WANT_READLINE AND WANT_LIBEDIT) OR (NOT WANT_READLINE AND NOT WANT_LIBEDIT))
message (SEND_ERROR "You have to choose either GNU Readline or libedit")
elseif (WANT_READLINE)
list (APPEND project_libraries readline)
# OpenBSD's default readline is too old
if ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
include_directories (/usr/local/include/ereadline)
list (APPEND project_libraries ereadline)
else ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
list (APPEND project_libraries readline)
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
elseif (WANT_LIBEDIT)
pkg_check_modules (libedit REQUIRED libedit)
list (APPEND project_libraries ${libedit_LIBRARIES})

View File

@ -59,7 +59,7 @@ enum
#include <wchar.h>
#include <termios.h>
#ifndef TIOCGWINSZ
#ifdef TIOCGWINSZ
#include <sys/ioctl.h>
#endif // ! TIOCGWINSZ