Fix build on *BSD

This commit is contained in:
Přemysl Eric Janouch 2016-01-14 20:46:34 +01:00
parent ae4c89e5a7
commit b261401c72
1 changed files with 16 additions and 0 deletions

View File

@ -7,6 +7,14 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
set (CMAKE_C_FLAGS "-std=c99 -Wall -Wextra -Wno-unused-function")
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
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")
# Build options
option (USE_SYSTEM_TERMO "Don't compile our own termo, use the system one" OFF)
@ -45,6 +53,14 @@ set (project_libraries ${LIBEV_LIBRARIES} ${Termo_LIBRARIES}
include_directories (${LIBEV_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS}
${NCURSESW_INCLUDE_DIRS})
# -liconv may or may not be a part of libc
foreach (extra iconv)
find_library (extra_lib_${extra} ${extra})
if (extra_lib_${extra})
list (APPEND project_libraries ${extra})
endif (extra_lib_${extra})
endforeach (extra)
# Configuration
include (CheckFunctionExists)
set (CMAKE_REQUIRED_LIBRARIES ${project_libraries})