src/CMakeLists.txt
author Tero Marttila <terom@fixme.fi>
Wed, 27 May 2009 23:57:48 +0300
branchnew-lib-errors
changeset 217 7728d6ec3abf
parent 203 ffdf53fd0337
child 219 cefec18b8268
permissions -rw-r--r--
nexus.c compiles
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
# dependancies
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
find_package (LibEvent REQUIRED)
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
find_package (GnuTLS REQUIRED)
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 59
diff changeset
     4
find_package (LibPQ REQUIRED)
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 59
diff changeset
     5
find_package (Evsql REQUIRED)
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 92
diff changeset
     6
find_package (Lua51 REQUIRED)
121
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
     7
find_package (PCRE REQUIRED)
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
# add our include path
121
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
    10
include_directories (${LibEvent_INCLUDE_DIRS} ${GnuTLS_INCLUDE_DIRS} ${Evsql_INCLUDE_DIRS} ${Lua51_INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS})
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
217
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    12
# XXX: hack until we separate these
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    13
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    14
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
# define our source code modules
217
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    16
set (LIB_SOURCES lib/error.c lib/log.c lib/str.c lib/object.c)
196
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 191
diff changeset
    17
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)
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 191
diff changeset
    18
set (PROTO_SOURCES line_proto.c msg_proto.c)
153
d35e7cb3a489 implement irc_net reconnect, requires testing
Tero Marttila <terom@fixme.fi>
parents: 143
diff changeset
    19
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)
203
ffdf53fd0337 implement lua_threads, nexus:sleep test func, and basic support in console/lua_console... doesn't actually work yet
Tero Marttila <terom@fixme.fi>
parents: 196
diff changeset
    20
set (LUA_SOURCES nexus_lua.c lua_objs.c lua_config.c lua_irc.c lua_func.c lua_type.c lua_thread.c)
105
b6b183fbf373 implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
    21
set (CONSOLE_SOURCES console.c lua_console.c)
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
217
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    23
set (SPBOT_SOURCES spbot/nexus.c spbot/signals.c spbot/module.c spbot/config.c)
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    24
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 203
diff changeset
    25
set (NEXUS_SOURCES ${SPBOT_SOURCES} ${LIB_SOURCES} ${IO_SOURCES} ${PROTO_SOURCES} ${IRC_SOURCES} ${LUA_SOURCES} ${CONSOLE_SOURCES})
117
9cb405164250 move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    26
set (IRC_LOG_SOURCES modules/irc_log.c)
133
e2d0c0c23b39 implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents: 126
diff changeset
    27
set (LOGWATCH_SOURCES modules/logwatch.c modules/logwatch_source.c modules/logwatch_filter.c modules/logwatch_chan.c)
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
# define our libraries
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
set (MODULE_LIBRARIES "dl")
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 92
diff changeset
    31
set (NEXUS_LIBRARIES ${LibEvent_LIBRARIES} ${GnuTLS_LIBRARIES} ${MODULE_LIBRARIES} "readline" ${Lua51_LIBRARIES})
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
# compiler flags
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    34
set (CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99")
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
# add our binaries
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
add_executable (nexus ${NEXUS_SOURCES})
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
# add our modules
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
add_library (irc_log MODULE ${IRC_LOG_SOURCES})
119
64f50072db9e add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents: 118
diff changeset
    41
add_library (logwatch MODULE ${LOGWATCH_SOURCES})
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
# set libraries
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
target_link_libraries (nexus ${NEXUS_LIBRARIES})
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 59
diff changeset
    45
target_link_libraries (irc_log ${Evsql_LIBRARIES})
121
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
    46
target_link_libraries (logwatch ${PCRE_LIBRARIES})
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
# nexus needs to export its symbols to be able to load modules
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
set_target_properties (nexus PROPERTIES
187
5d100c79521a fix CMake TEST_OBJECT_PATH, ENABLE_TEST_COVERAGE test-target and cleanup of .gcda's
Tero Marttila <terom@fixme.fi>
parents: 186
diff changeset
    50
    # XXX: use ENABLE_EXPORTS?
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
    LINK_FLAGS      "--export-dynamic"
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
)
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
# modules have weird names
119
64f50072db9e add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents: 118
diff changeset
    55
set_target_properties (irc_log logwatch PROPERTIES
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 59
diff changeset
    56
    PREFIX                      "mod_"
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
    LIBRARY_OUTPUT_DIRECTORY    "modules"
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
)
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
186
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    60
# test stuff
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    61
if (ENABLE_TEST)
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    62
    # build list of source files
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    63
    file (GLOB _TEST_SOURCES "test/*.c")
196
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 191
diff changeset
    64
    set (TEST_SOURCES ${_TEST_SOURCES} ${CORE_SOURCES} ${IO_SOURCES} ${PROTO_SOURCES} transport_test.c ${IRC_SOURCES})
186
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    65
    
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    66
    # add executable target and link against libs
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    67
    add_executable (test_harness EXCLUDE_FROM_ALL ${TEST_SOURCES})
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    68
    target_link_libraries (test_harness ${NEXUS_LIBRARIES})
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    69
    
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    70
    if (ENABLE_TEST_COVERAGE)
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    71
        # test should enable code coverage instrumentation
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    72
        set (TEST_CFLAGS "-fprofile-arcs -ftest-coverage")
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    73
        set (TEST_LFLAGS "-fprofile-arcs -ftest-coverage")
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    74
    
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    75
    endif (ENABLE_TEST_COVERAGE)
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    76
    
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    77
    # set the correct output file name and cc/ld flags
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    78
    set_target_properties (test_harness PROPERTIES
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    79
        OUTPUT_NAME                 "test"
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    80
        COMPILE_FLAGS               ${TEST_CFLAGS}
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    81
        LINK_FLAGS                  ${TEST_LFLAGS}
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    82
    )
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    83
191
031582f7b61b add support for valgrind to test, and update old suppressions file
Tero Marttila <terom@fixme.fi>
parents: 187
diff changeset
    84
    # path to the test harness executable
031582f7b61b add support for valgrind to test, and update old suppressions file
Tero Marttila <terom@fixme.fi>
parents: 187
diff changeset
    85
    get_target_property (TEST_EXECUTABLE test_harness LOCATION)
031582f7b61b add support for valgrind to test, and update old suppressions file
Tero Marttila <terom@fixme.fi>
parents: 187
diff changeset
    86
186
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    87
    # path to directory containing the .o/.gcdo/.gcno files for the test harness
191
031582f7b61b add support for valgrind to test, and update old suppressions file
Tero Marttila <terom@fixme.fi>
parents: 187
diff changeset
    88
    get_filename_component (TEST_OBJECT_DIR ${TEST_EXECUTABLE} PATH)
187
5d100c79521a fix CMake TEST_OBJECT_PATH, ENABLE_TEST_COVERAGE test-target and cleanup of .gcda's
Tero Marttila <terom@fixme.fi>
parents: 186
diff changeset
    89
5d100c79521a fix CMake TEST_OBJECT_PATH, ENABLE_TEST_COVERAGE test-target and cleanup of .gcda's
Tero Marttila <terom@fixme.fi>
parents: 186
diff changeset
    90
    # XXX: ugly hardcoding of CMake internals, but I can't find anything else for this
5d100c79521a fix CMake TEST_OBJECT_PATH, ENABLE_TEST_COVERAGE test-target and cleanup of .gcda's
Tero Marttila <terom@fixme.fi>
parents: 186
diff changeset
    91
    set (TEST_OBJECT_DIR ${TEST_OBJECT_DIR}/CMakeFiles/test_harness.dir PARENT_SCOPE)
191
031582f7b61b add support for valgrind to test, and update old suppressions file
Tero Marttila <terom@fixme.fi>
parents: 187
diff changeset
    92
    set (TEST_EXECUTABLE ${TEST_EXECUTABLE} PARENT_SCOPE)
186
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    93
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    94
endif (ENABLE_TEST)
33ef336dbb4b rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
Tero Marttila <terom@fixme.fi>
parents: 180
diff changeset
    95
59
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
## setup install info
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
#install (TARGETS evirc
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
#    LIBRARY         DESTINATION lib
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
#    ARCHIVE         DESTINATION lib/static
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
#    PUBLIC_HEADER   DESTINATION include
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
#)
375a3b5c3a46 add CMake build stuff... that was easy
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102