# dependancies
find_package (LibEvent REQUIRED)
find_package (GnuTLS REQUIRED)
find_package (LibPQ REQUIRED)
find_package (Evsql REQUIRED)
find_package (Lua51 REQUIRED)
find_package (PCRE REQUIRED)
# add our include path
include_directories (${LibEvent_INCLUDE_DIRS} ${GnuTLS_INCLUDE_DIRS} ${Evsql_INCLUDE_DIRS} ${Lua51_INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS})
# define our source code modules
set (CORE_SOURCES error.c log.c str.c)
set (IO_SOURCES transport.c transport_fd.c sock.c sock_tcp.c sock_gnutls.c fifo.c line_proto.c)
set (IRC_SOURCES irc_line.c irc_conn.c irc_net.c irc_chan.c chain.c irc_cmd.c irc_proto.c irc_client.c irc_user.c irc_queue.c irc_net_connect.c)
set (LUA_SOURCES nexus_lua.c lua_objs.c lua_config.c lua_irc.c lua_func.c lua_type.c)
set (CONSOLE_SOURCES console.c lua_console.c)
file (GLOB _TEST_SOURCES "test/*.c")
set (NEXUS_SOURCES nexus.c ${CORE_SOURCES} ${IO_SOURCES} ${IRC_SOURCES} ${LUA_SOURCES} ${CONSOLE_SOURCES} signals.c module.c config.c)
set (TEST_SOURCES ${_TEST_SOURCES} ${CORE_SOURCES} ${IO_SOURCES} transport_test.c ${IRC_SOURCES})
set (IRC_LOG_SOURCES modules/irc_log.c)
set (LOGWATCH_SOURCES modules/logwatch.c modules/logwatch_source.c modules/logwatch_filter.c modules/logwatch_chan.c)
# define our libraries
set (MODULE_LIBRARIES "dl")
set (NEXUS_LIBRARIES ${LibEvent_LIBRARIES} ${GnuTLS_LIBRARIES} ${MODULE_LIBRARIES} "readline" ${Lua51_LIBRARIES})
# compiler flags
set (CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99")
# add our binaries
add_executable (nexus ${NEXUS_SOURCES})
add_executable (test EXCLUDE_FROM_ALL ${TEST_SOURCES})
# add our modules
add_library (irc_log MODULE ${IRC_LOG_SOURCES})
add_library (logwatch MODULE ${LOGWATCH_SOURCES})
# set libraries
target_link_libraries (nexus ${NEXUS_LIBRARIES})
target_link_libraries (test ${NEXUS_LIBRARIES})
target_link_libraries (irc_log ${Evsql_LIBRARIES})
target_link_libraries (logwatch ${PCRE_LIBRARIES})
# nexus needs to export its symbols to be able to load modules
set_target_properties (nexus PROPERTIES
LINK_FLAGS "--export-dynamic"
)
# modules have weird names
set_target_properties (irc_log logwatch PROPERTIES
PREFIX "mod_"
LIBRARY_OUTPUT_DIRECTORY "modules"
)
## setup install info
#install (TARGETS evirc
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib/static
# PUBLIC_HEADER DESTINATION include
#)