diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-04-30 16:25:09 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-04-30 21:02:45 -0400 |
commit | adc8598dcb19ac70c588b6298418df7b7c274bc2 (patch) | |
tree | 6fdb80981688d9ef1bb53e3696bb383a89135c88 /cmake | |
parent | ef9b000d39e2c1092ec4d98ce135eff385c05f4b (diff) | |
download | libgd-adc8598dcb19ac70c588b6298418df7b7c274bc2.tar.gz |
tests: unify cmake test code into a single macro
This makes the test code a lot easier to manage rather than copying &
pasting the same boiler plate multiple times.
Also take the opportunity to add a common prefix to each test name so
we don't get collisions between subdirs if a test happens to use the
same exact name.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/gd.cmake | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/modules/gd.cmake b/cmake/modules/gd.cmake index 1e846dd..bef21f9 100644 --- a/cmake/modules/gd.cmake +++ b/cmake/modules/gd.cmake @@ -1 +1,13 @@ option(BUILD_TEST "Compile examples in the build tree and enable ctest" OFF) + +# This expects TESTS_FILES to already be defined to the lists of tests. +# Extra libs can be passed in as the 1st argument. +MACRO(ADD_GD_TESTS) + GET_FILENAME_COMPONENT(TEST_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) + FOREACH(test_name ${TESTS_FILES}) + SET(test_prog_name "test_${TEST_PREFIX}_${test_name}") + add_executable(${test_prog_name} "${test_name}.c") + target_link_libraries (${test_prog_name} gdTest ${ARGV0}) + add_test(NAME ${test_prog_name} COMMAND ${test_prog_name}) + ENDFOREACH(test_name) +ENDMACRO(ADD_GD_TESTS) |