Factor out the zint_add_test macro

This commit is contained in:
Schaich 2021-03-29 23:46:13 +09:00
parent b69df5ad91
commit 3114a6697b
3 changed files with 19 additions and 23 deletions

View file

@ -8,6 +8,8 @@ project(zint_backend_tests)
enable_testing()
include(${zint-package_SOURCE_DIR}/cmake/zint_add_test.cmake)
file(GLOB_RECURSE zint_backend_tests_data LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/*")
foreach(data_file IN LISTS zint_backend_tests_data)
configure_file(${data_file} ${data_file} COPYONLY)
@ -33,18 +35,6 @@ if(ZINT_STATIC)
target_include_directories(testcommon-static PUBLIC ${zint_backend_tests_SOURCE_DIR})
endif()
macro(zint_add_test test_name test_command)
set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS})
add_executable(${test_command} ${test_command}.c)
target_link_libraries(${test_command} testcommon ${ADDITIONAL_LIBS})
add_test(${test_name} ${test_command})
if(ZINT_STATIC)
add_executable(${test_command}-static ${test_command}.c)
target_link_libraries(${test_command}-static testcommon-static ${ADDITIONAL_LIBS})
add_test(${test_name}-static ${test_command}-static)
endif()
endmacro()
zint_add_test(2of5 test_2of5)
zint_add_test(auspost test_auspost)
zint_add_test(aztec test_aztec)

16
cmake/zint_add_test.cmake Normal file
View file

@ -0,0 +1,16 @@
# Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
# Adapted from qrencode/tests/CMakeLists.txt
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
# vim: set ts=4 sw=4 et :
macro(zint_add_test test_name test_command)
set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS})
add_executable(${test_command} ${test_command}.c)
target_link_libraries(${test_command} testcommon ${ADDITIONAL_LIBS})
add_test(${test_name} ${test_command})
if(ZINT_STATIC)
add_executable(${test_command}-static ${test_command}.c)
target_link_libraries(${test_command}-static testcommon-static ${ADDITIONAL_LIBS})
add_test(${test_name}-static ${test_command}-static)
endif()
endmacro()

View file

@ -8,16 +8,6 @@ project(zint_frontend_tests)
enable_testing()
macro(zint_add_test test_name test_command)
set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS})
add_executable(${test_command} ${test_command}.c)
target_link_libraries(${test_command} testcommon ${ADDITIONAL_LIBS})
add_test(${test_name} ${test_command})
if(ZINT_STATIC)
add_executable(${test_command}-static ${test_command}.c)
target_link_libraries(${test_command}-static testcommon-static ${ADDITIONAL_LIBS})
add_test(${test_name}-static ${test_command}-static)
endif()
endmacro()
include(${zint-package_SOURCE_DIR}/cmake/zint_add_test.cmake)
zint_add_test(args test_args)