src/CMakeLists.txt
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 217 7728d6ec3abf
permissions -rw-r--r--
some of the lib/transport stuff compiles
# 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})

# XXX: hack until we separate these
include_directories (${CMAKE_CURRENT_SOURCE_DIR})

# define our source code modules
set (LIB_SOURCES lib/error.c lib/log.c lib/str.c lib/object.c)
set (IO_SOURCES lib/transport.c lib/service.c lib/transport_fd.c lib/sock.c lib/resolve.c lib/tcp.c lib/tcp_transport.c lib/tcp_client.c lib/tcp_server.c lib/ssl.c lib/ssl_client.c lib/fifo.c)
set (PROTO_SOURCES lib/line_proto.c lib/msg_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 spbot/lua_objs.c spbot/lua_config.c lua_irc.c lib/lua_func.c lib/lua_type.c spbot/lua_thread.c)
set (CONSOLE_SOURCES lib/console.c spbot/lua_console.c)

set (SPBOT_SOURCES spbot/nexus.c spbot/signals.c spbot/module.c spbot/config.c spbot/nexus_lua.c)

set (NEXUS_SOURCES ${SPBOT_SOURCES} ${LIB_SOURCES} ${IO_SOURCES} ${PROTO_SOURCES} ${IRC_SOURCES} ${LUA_SOURCES} ${CONSOLE_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 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 (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
    # XXX: use ENABLE_EXPORTS?
    LINK_FLAGS      "--export-dynamic"
)

# modules have weird names
set_target_properties (irc_log logwatch PROPERTIES
    PREFIX                      "mod_"
    LIBRARY_OUTPUT_DIRECTORY    "modules"
)

# test stuff
if (ENABLE_TEST)
    # build list of source files
    file (GLOB _TEST_SOURCES "test/*.c")
    set (TEST_SOURCES ${_TEST_SOURCES} ${CORE_SOURCES} ${IO_SOURCES} ${PROTO_SOURCES} lib/transport_test.c ${IRC_SOURCES})
    
    # add executable target and link against libs
    add_executable (test_harness EXCLUDE_FROM_ALL ${TEST_SOURCES})
    target_link_libraries (test_harness ${NEXUS_LIBRARIES})
    
    if (ENABLE_TEST_COVERAGE)
        # test should enable code coverage instrumentation
        set (TEST_CFLAGS "-fprofile-arcs -ftest-coverage")
        set (TEST_LFLAGS "-fprofile-arcs -ftest-coverage")
    
    endif (ENABLE_TEST_COVERAGE)
    
    # set the correct output file name and cc/ld flags
    set_target_properties (test_harness PROPERTIES
        OUTPUT_NAME                 "test"
        COMPILE_FLAGS               ${TEST_CFLAGS}
        LINK_FLAGS                  ${TEST_LFLAGS}
    )

    # path to the test harness executable
    get_target_property (TEST_EXECUTABLE test_harness LOCATION)

    # path to directory containing the .o/.gcdo/.gcno files for the test harness
    get_filename_component (TEST_OBJECT_DIR ${TEST_EXECUTABLE} PATH)

    # XXX: ugly hardcoding of CMake internals, but I can't find anything else for this
    set (TEST_OBJECT_DIR ${TEST_OBJECT_DIR}/CMakeFiles/test_harness.dir PARENT_SCOPE)
    set (TEST_EXECUTABLE ${TEST_EXECUTABLE} PARENT_SCOPE)

endif (ENABLE_TEST)

## setup install info
#install (TARGETS evirc
#    LIBRARY         DESTINATION lib
#    ARCHIVE         DESTINATION lib/static
#    PUBLIC_HEADER   DESTINATION include
#)