diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index 8151c993..63b32497 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -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) diff --git a/cmake/zint_add_test.cmake b/cmake/zint_add_test.cmake new file mode 100644 index 00000000..29c88f61 --- /dev/null +++ b/cmake/zint_add_test.cmake @@ -0,0 +1,16 @@ +# Copyright (C) 2020 Robin Stuart +# Adapted from qrencode/tests/CMakeLists.txt +# Copyright (C) 2006-2017 Kentaro Fukuchi +# 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() diff --git a/frontend/tests/CMakeLists.txt b/frontend/tests/CMakeLists.txt index 7d06f8a7..e4e6fa85 100644 --- a/frontend/tests/CMakeLists.txt +++ b/frontend/tests/CMakeLists.txt @@ -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)