# Copyright (C) 2020 Tycho Softworks.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

file(GLOB server_src *.cpp)
file(GLOB server_hdr *.hpp)
file(GLOB server_man5 *.5)
file(GLOB server_man8 *.8)

set(server_libs ${EXOSIP_LIBS} fmt::fmt)
if(MALLOC_FOUND)
    list(APPEND server_libs PkgConfig::MALLOC)
endif()

if(SYSTEMD_FOUND)
    list(APPEND server_libs ${SYSTEMD_LIBRARIES})
endif()

add_executable(coventry ${server_src} ${server_hdr} coventry.conf ${server_man5} ${server_man8})
target_link_libraries(coventry PRIVATE ${server_libs})

install(TARGETS coventry DESTINATION "${CMAKE_INSTALL_SBINDIR}")
install(FILES coventry.conf DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}")
install(FILES ${server_man5} DESTINATION "${CMAKE_INSTALL_MANDIR}/man5")
install(FILES ${server_man8} DESTINATION "${CMAKE_INSTALL_MANDIR}/man8")
