terom@59: # dependancies terom@59: find_package (LibEvent REQUIRED) terom@59: find_package (GnuTLS REQUIRED) terom@67: find_package (LibPQ REQUIRED) terom@67: find_package (Evsql REQUIRED) terom@93: find_package (Lua51 REQUIRED) terom@121: find_package (PCRE REQUIRED) terom@59: terom@59: # add our include path terom@121: include_directories (${LibEvent_INCLUDE_DIRS} ${GnuTLS_INCLUDE_DIRS} ${Evsql_INCLUDE_DIRS} ${Lua51_INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS}) terom@59: terom@217: # XXX: hack until we separate these terom@217: include_directories (${CMAKE_CURRENT_SOURCE_DIR}) terom@217: terom@59: # define our source code modules terom@217: set (LIB_SOURCES lib/error.c lib/log.c lib/str.c lib/object.c) terom@196: set (IO_SOURCES transport.c service.c transport_fd.c sock.c resolve.c tcp.c tcp_transport.c tcp_client.c tcp_server.c ssl.c ssl_client.c fifo.c) terom@196: set (PROTO_SOURCES line_proto.c msg_proto.c) terom@153: 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) terom@203: set (LUA_SOURCES nexus_lua.c lua_objs.c lua_config.c lua_irc.c lua_func.c lua_type.c lua_thread.c) terom@105: set (CONSOLE_SOURCES console.c lua_console.c) terom@59: terom@217: set (SPBOT_SOURCES spbot/nexus.c spbot/signals.c spbot/module.c spbot/config.c) terom@217: terom@217: set (NEXUS_SOURCES ${SPBOT_SOURCES} ${LIB_SOURCES} ${IO_SOURCES} ${PROTO_SOURCES} ${IRC_SOURCES} ${LUA_SOURCES} ${CONSOLE_SOURCES}) terom@117: set (IRC_LOG_SOURCES modules/irc_log.c) terom@133: set (LOGWATCH_SOURCES modules/logwatch.c modules/logwatch_source.c modules/logwatch_filter.c modules/logwatch_chan.c) terom@59: terom@59: # define our libraries terom@59: set (MODULE_LIBRARIES "dl") terom@93: set (NEXUS_LIBRARIES ${LibEvent_LIBRARIES} ${GnuTLS_LIBRARIES} ${MODULE_LIBRARIES} "readline" ${Lua51_LIBRARIES}) terom@59: terom@59: # compiler flags terom@168: set (CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99") terom@59: terom@59: # add our binaries terom@59: add_executable (nexus ${NEXUS_SOURCES}) terom@59: terom@59: # add our modules terom@59: add_library (irc_log MODULE ${IRC_LOG_SOURCES}) terom@119: add_library (logwatch MODULE ${LOGWATCH_SOURCES}) terom@59: terom@59: # set libraries terom@59: target_link_libraries (nexus ${NEXUS_LIBRARIES}) terom@67: target_link_libraries (irc_log ${Evsql_LIBRARIES}) terom@121: target_link_libraries (logwatch ${PCRE_LIBRARIES}) terom@59: terom@59: # nexus needs to export its symbols to be able to load modules terom@59: set_target_properties (nexus PROPERTIES terom@187: # XXX: use ENABLE_EXPORTS? terom@59: LINK_FLAGS "--export-dynamic" terom@59: ) terom@59: terom@59: # modules have weird names terom@119: set_target_properties (irc_log logwatch PROPERTIES terom@67: PREFIX "mod_" terom@59: LIBRARY_OUTPUT_DIRECTORY "modules" terom@59: ) terom@59: terom@186: # test stuff terom@186: if (ENABLE_TEST) terom@186: # build list of source files terom@186: file (GLOB _TEST_SOURCES "test/*.c") terom@196: set (TEST_SOURCES ${_TEST_SOURCES} ${CORE_SOURCES} ${IO_SOURCES} ${PROTO_SOURCES} transport_test.c ${IRC_SOURCES}) terom@186: terom@186: # add executable target and link against libs terom@186: add_executable (test_harness EXCLUDE_FROM_ALL ${TEST_SOURCES}) terom@186: target_link_libraries (test_harness ${NEXUS_LIBRARIES}) terom@186: terom@186: if (ENABLE_TEST_COVERAGE) terom@186: # test should enable code coverage instrumentation terom@186: set (TEST_CFLAGS "-fprofile-arcs -ftest-coverage") terom@186: set (TEST_LFLAGS "-fprofile-arcs -ftest-coverage") terom@186: terom@186: endif (ENABLE_TEST_COVERAGE) terom@186: terom@186: # set the correct output file name and cc/ld flags terom@186: set_target_properties (test_harness PROPERTIES terom@186: OUTPUT_NAME "test" terom@186: COMPILE_FLAGS ${TEST_CFLAGS} terom@186: LINK_FLAGS ${TEST_LFLAGS} terom@186: ) terom@186: terom@191: # path to the test harness executable terom@191: get_target_property (TEST_EXECUTABLE test_harness LOCATION) terom@191: terom@186: # path to directory containing the .o/.gcdo/.gcno files for the test harness terom@191: get_filename_component (TEST_OBJECT_DIR ${TEST_EXECUTABLE} PATH) terom@187: terom@187: # XXX: ugly hardcoding of CMake internals, but I can't find anything else for this terom@187: set (TEST_OBJECT_DIR ${TEST_OBJECT_DIR}/CMakeFiles/test_harness.dir PARENT_SCOPE) terom@191: set (TEST_EXECUTABLE ${TEST_EXECUTABLE} PARENT_SCOPE) terom@186: terom@186: endif (ENABLE_TEST) terom@186: terom@59: ## setup install info terom@59: #install (TARGETS evirc terom@59: # LIBRARY DESTINATION lib terom@59: # ARCHIVE DESTINATION lib/static terom@59: # PUBLIC_HEADER DESTINATION include terom@59: #) terom@59: