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) pkg_check_modules (ncursesw ncursesw)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD") if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# iconv() doesn't have to be present in libc include_directories(/usr/local/include)
# FIXME: detect if we need the library independently on the platform link_directories(/usr/local/lib)
list (APPEND project_libraries iconv) # Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
# Need this for SIGWINCH; our POSIX version macros make it undefined # our POSIX version macros make it undefined
add_definitions (-D__BSD_VISIBLE=1) add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD") 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) # -lpthread is only there for debugging (gdb & errno)
# -lrt is only for glibc < 2.17 # -lrt is only for glibc < 2.17
list (APPEND project_libraries ${libssl_LIBRARIES} rt pthread) foreach (extra rt pthread)
include_directories (${libssl_INCLUDE_DIRS}) find_library (extra_lib ${extra})
link_directories (${libssl_LIBRARY_DIRS}) if (extra_lib)
list (APPEND project_libraries ${extra})
endif (extra_lib)
endforeach (extra)
if (ncursesw_FOUND) if (ncursesw_FOUND)
list (APPEND project_libraries ${ncursesw_LIBRARIES}) 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)) 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") message (SEND_ERROR "You have to choose either GNU Readline or libedit")
elseif (WANT_READLINE) elseif (WANT_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) list (APPEND project_libraries readline)
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
elseif (WANT_LIBEDIT) elseif (WANT_LIBEDIT)
pkg_check_modules (libedit REQUIRED libedit) pkg_check_modules (libedit REQUIRED libedit)
list (APPEND project_libraries ${libedit_LIBRARIES}) list (APPEND project_libraries ${libedit_LIBRARIES})

View File

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