From 1b3e80423a7b9cb2b6330e8dd00a515f94b736c8 Mon Sep 17 00:00:00 2001 From: Andreas Schenk <andreas_schenk@hms.harvard.edu> Date: Mon, 21 Mar 2011 18:21:39 -0400 Subject: [PATCH] changed unittest macro to allow for link dependencies --- cmake_support/OST.cmake | 8 ++++++-- modules/base/tests/CMakeLists.txt | 4 ++-- modules/gfx/tests/CMakeLists.txt | 4 ++-- modules/img/base/tests/CMakeLists.txt | 5 ++--- modules/io/tests/CMakeLists.txt | 5 ++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake index 1465229fc..2f48ea60c 100644 --- a/cmake_support/OST.cmake +++ b/cmake_support/OST.cmake @@ -537,7 +537,7 @@ endif() macro(ost_unittest) set(_ARG_PREFIX ost) parse_argument_list(_ARG - "MODULE;PREFIX;SOURCES" "" ${ARGN}) + "MODULE;PREFIX;SOURCES;LINK" "" ${ARGN}) set(_SOURCES ${_ARG_SOURCES}) set(CPP_TESTS) set(PY_TESTS) @@ -550,7 +550,7 @@ macro(ost_unittest) endif() endforeach() set(_SOURCES ${CPP_TESTS}) - set(_test_name "${_ARG_MODULE}_tests") + set(_test_name "${_ARG_PREFIX}_${_ARG_MODULE}_tests") if(DEFINED CPP_TESTS) if(COMPILE_TESTS) add_executable(${_test_name} ${_SOURCES}) @@ -575,6 +575,10 @@ macro(ost_unittest) DEPENDS ${_test_name}) add_test("${_test_name}" ${CMAKE_CURRENT_BINARY_DIR}/${_test_name} ) endif() + + if (_ARG_LINK) + target_link_libraries("${_test_name}" ${_ARG_LINK}) + endif() add_dependencies(check "${_test_name}_run") set_target_properties(${_test_name} diff --git a/modules/base/tests/CMakeLists.txt b/modules/base/tests/CMakeLists.txt index 1847b42be..c18fcda10 100644 --- a/modules/base/tests/CMakeLists.txt +++ b/modules/base/tests/CMakeLists.txt @@ -8,5 +8,5 @@ set(OST_BASE_UNIT_TESTS ) ost_unittest(MODULE base - SOURCES "${OST_BASE_UNIT_TESTS}") -target_link_libraries(base_tests ost_mol) + SOURCES "${OST_BASE_UNIT_TESTS}" + LINK ost_mol) diff --git a/modules/gfx/tests/CMakeLists.txt b/modules/gfx/tests/CMakeLists.txt index 1c67cb45a..469122e94 100644 --- a/modules/gfx/tests/CMakeLists.txt +++ b/modules/gfx/tests/CMakeLists.txt @@ -7,6 +7,6 @@ if (ENABLE_IMG) endif() ost_unittest(MODULE gfx - SOURCES "${OST_GFX_UNIT_TESTS}") + SOURCES "${OST_GFX_UNIT_TESTS}" + LINK ost_io) -target_link_libraries(gfx_tests ost_io) diff --git a/modules/img/base/tests/CMakeLists.txt b/modules/img/base/tests/CMakeLists.txt index a568268f5..503345f16 100644 --- a/modules/img/base/tests/CMakeLists.txt +++ b/modules/img/base/tests/CMakeLists.txt @@ -17,7 +17,6 @@ tests.cc ost_unittest(MODULE img - SOURCES "${OST_IMG_BASE_UNIT_TESTS}") - -target_link_libraries(img_tests ost_img_alg) + SOURCES "${OST_IMG_BASE_UNIT_TESTS}" + LINK ost_img_alg) diff --git a/modules/io/tests/CMakeLists.txt b/modules/io/tests/CMakeLists.txt index cb21766c3..ae1d0dab1 100644 --- a/modules/io/tests/CMakeLists.txt +++ b/modules/io/tests/CMakeLists.txt @@ -11,9 +11,8 @@ set(OST_IO_UNIT_TESTS # missing: test_star_parser.cc ost_unittest(MODULE io - SOURCES "${OST_IO_UNIT_TESTS}") -target_link_libraries(io_tests ost_mol) -target_link_libraries(io_tests ost_seq) + SOURCES "${OST_IO_UNIT_TESTS}" + LINK ost_mol ost_seq) add_executable(test_mae_standalone test_mae_standalone.cc) target_link_libraries(test_mae_standalone ost_mol) -- GitLab