Commit 38c251ae authored by Thomas Moulard's avatar Thomas Moulard

Clean unit tests compilation.

parent 71f7c54f
......@@ -65,7 +65,7 @@ ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(unitTesting)
ADD_SUBDIRECTORY(tests)
SETUP_PROJECT_FINALIZE()
SETUP_PROJECT_CPACK()
\ No newline at end of file
......@@ -13,53 +13,45 @@
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
# Declare boost include directories
include_directories(${Boost_INCLUDE_DIRS})
### tests
SET(tests_exe
test_pool
test_depend
test_signalcast)
SET(tests_libs
test_signalcast_libA
test_signalcast_libB
)
SET(test_signalcast_additional_libs ${test_libs})
ADD_DEFINITIONS(-DDEBUG=2)
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
# Add Boost path to include directories.
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# Additional tests
FOREACH(test_name ${tests_libs})
SET(LIBRARY_NAME ${test_name})
# Make Boost.Test generates the main function in test cases.
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
# DYNAMIC_GRAPH_TEST(NAME)
# ------------------------
#
# Define a test named `NAME'.
#
# This macro will create a binary from `NAME.cpp', link it against
# Boost and add it to the test suite.
#
MACRO(DYNAMIC_GRAPH_TEST NAME)
ADD_EXECUTABLE(${NAME} ${NAME}.cpp)
ADD_TEST(${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/${NAME})
ADD_LIBRARY(${LIBRARY_NAME}
SHARED
${test_name}.cpp)
TARGET_LINK_LIBRARIES(${NAME} ${PROJECT_NAME})
ADD_DEPENDENCIES(${NAME} ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${PROJECT_NAME})
ADD_DEPENDENCIES(${LIBRARY_NAME}
${PROJECT_NAME})
ENDFOREACH(test_name)
# Link against Boost.
TARGET_LINK_LIBRARIES(${NAME} ${Boost_LIBRARIES})
ENDMACRO(DYNAMIC_GRAPH_TEST)
FOREACH(test_name ${tests_exe})
SET(EXECUTABLE_NAME ${test_name})
DYNAMIC_GRAPH_TEST(test_pool)
DYNAMIC_GRAPH_TEST(test_depend)
ADD_EXECUTABLE(${EXECUTABLE_NAME}
${test_name}.cpp)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
${PROJECT_NAME})
ADD_DEPENDENCIES(${EXECUTABLE_NAME}
${PROJECT_NAME})
# Signal cast test.
SET(signalcast_libs test_signalcast_libA test_signalcast_libB)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
${${test_name}_additional_libs})
FOREACH(lib ${signalcast_libs})
ADD_LIBRARY(${lib} SHARED ${lib}.cpp)
ADD_TEST(NAME ${test_name} COMMAND ${test_name})
ENDFOREACH(test_name)
TARGET_LINK_LIBRARIES(${lib} ${PROJECT_NAME})
ADD_DEPENDENCIES(${lib} ${PROJECT_NAME})
ENDFOREACH()
DYNAMIC_GRAPH_TEST(test_signalcast)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${signalcast_libs})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment