--- a/src/CMakeLists.txt Thu May 07 18:48:38 2009 +0300
+++ b/src/CMakeLists.txt Thu May 07 22:23:51 2009 +0300
@@ -15,10 +15,8 @@
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)
@@ -31,7 +29,6 @@
# 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})
@@ -39,7 +36,6 @@
# 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})
@@ -54,6 +50,35 @@
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} 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 directory containing the .o/.gcdo/.gcno files for the test harness
+ set (TEST_OBJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
+
+endif (ENABLE_TEST)
+
## setup install info
#install (TARGETS evirc
# LIBRARY DESTINATION lib