2021-03-09 01:34:34 +13:00
|
|
|
# Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
2019-09-02 08:09:47 +12:00
|
|
|
# Adapted from qrencode/tests/CMakeLists.txt
|
|
|
|
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
|
2020-06-15 01:42:40 +12:00
|
|
|
# vim: set ts=4 sw=4 et :
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2020-05-06 09:28:25 +12:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
2020-10-04 10:51:08 +13:00
|
|
|
project(zint_backend_tests)
|
2019-09-02 08:09:47 +12:00
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
2020-05-06 09:28:25 +12:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
2019-09-02 08:09:47 +12:00
|
|
|
|
|
|
|
set(ZINT_DEBUG FALSE CACHE BOOL "Set debug compile flag")
|
|
|
|
set(ZINT_SANITIZE FALSE CACHE BOOL "Set sanitize compile/link flags")
|
2019-12-19 13:37:55 +13:00
|
|
|
set(ZINT_TEST FALSE CACHE BOOL "Set test compile flag")
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2020-08-05 09:22:26 +12:00
|
|
|
find_package(LibZint REQUIRED)
|
2019-10-14 21:49:15 +13:00
|
|
|
find_package(PNG)
|
|
|
|
|
2021-03-09 01:34:34 +13:00
|
|
|
if(NOT PNG_FOUND)
|
2019-10-14 21:49:15 +13:00
|
|
|
add_definitions(-DNO_PNG)
|
2020-05-06 09:28:25 +12:00
|
|
|
endif()
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2020-07-11 06:39:32 +12:00
|
|
|
set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz)
|
|
|
|
set(BWIPP_PS ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps)
|
|
|
|
|
|
|
|
if(NOT EXISTS ${BWIPP_PS})
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${BWIPP_TAR}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools)
|
|
|
|
endif()
|
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
|
|
|
|
check_c_compiler_flag(-Wall C_COMPILER_FLAG_WALL)
|
|
|
|
if(C_COMPILER_FLAG_WALL)
|
|
|
|
add_compile_options("-Wall")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_c_compiler_flag(-Wextra C_COMPILER_FLAG_WEXTRA)
|
|
|
|
if(C_COMPILER_FLAG_WEXTRA)
|
|
|
|
add_compile_options("-Wextra")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZINT_DEBUG)
|
|
|
|
check_c_compiler_flag(-g C_COMPILER_FLAG_G)
|
|
|
|
if(C_COMPILER_FLAG_G)
|
2019-09-02 08:09:47 +12:00
|
|
|
add_compile_options("-g")
|
2020-05-06 09:28:25 +12:00
|
|
|
endif()
|
2020-10-04 10:51:08 +13:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZINT_SANITIZE)
|
|
|
|
# check_c_compiler_flag fails for -fsanitize
|
|
|
|
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
2019-09-02 08:09:47 +12:00
|
|
|
add_compile_options("-fsanitize=undefined")
|
|
|
|
add_compile_options("-fsanitize=address")
|
2020-10-04 10:51:08 +13:00
|
|
|
link_libraries("-fsanitize=undefined -fsanitize=address")
|
2020-05-06 09:28:25 +12:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
if(ZINT_TEST)
|
|
|
|
add_definitions("-DZINT_TEST")
|
|
|
|
endif()
|
|
|
|
|
2020-06-15 01:42:40 +12:00
|
|
|
add_library(testcommon testcommon.c testcommon.h)
|
2020-05-06 09:28:25 +12:00
|
|
|
if(PNG_FOUND)
|
2021-03-09 01:34:34 +13:00
|
|
|
target_link_libraries(testcommon ZINT::ZINT PNG::PNG)
|
2020-05-06 09:28:25 +12:00
|
|
|
else()
|
2019-10-14 21:49:15 +13:00
|
|
|
target_link_libraries(testcommon ZINT::ZINT)
|
2020-05-06 09:28:25 +12:00
|
|
|
endif()
|
2019-09-02 08:09:47 +12:00
|
|
|
|
|
|
|
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})
|
2020-06-15 01:42:40 +12:00
|
|
|
endmacro()
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
zint_add_test(2of5, test_2of5)
|
2020-03-26 04:40:13 +13:00
|
|
|
zint_add_test(auspost, test_auspost)
|
2020-03-29 11:50:55 +13:00
|
|
|
zint_add_test(aztec, test_aztec)
|
2021-01-12 07:11:41 +13:00
|
|
|
zint_add_test(big5, test_big5)
|
2020-06-05 05:45:25 +12:00
|
|
|
zint_add_test(bmp, test_bmp)
|
2019-09-02 08:09:47 +12:00
|
|
|
zint_add_test(channel, test_channel)
|
2020-03-26 08:27:34 +13:00
|
|
|
zint_add_test(codablock, test_codablock)
|
2020-06-05 05:45:25 +12:00
|
|
|
zint_add_test(code, test_code)
|
2020-03-28 23:13:06 +13:00
|
|
|
zint_add_test(code1, test_code1)
|
2020-04-03 09:55:58 +13:00
|
|
|
zint_add_test(code128, test_code128)
|
2020-05-22 05:22:28 +12:00
|
|
|
zint_add_test(code16k, test_code16k)
|
|
|
|
zint_add_test(code49, test_code49)
|
2019-11-28 05:16:14 +13:00
|
|
|
zint_add_test(common, test_common)
|
2019-10-15 10:20:16 +13:00
|
|
|
zint_add_test(composite, test_composite)
|
2019-11-28 05:16:14 +13:00
|
|
|
zint_add_test(dmatrix, test_dmatrix)
|
2020-03-26 11:31:59 +13:00
|
|
|
zint_add_test(dotcode, test_dotcode)
|
2019-09-02 08:09:47 +12:00
|
|
|
zint_add_test(eci, test_eci)
|
2020-05-06 09:51:04 +12:00
|
|
|
zint_add_test(emf, test_emf)
|
2019-12-09 05:15:34 +13:00
|
|
|
zint_add_test(gb18030, test_gb18030)
|
2019-11-29 08:15:29 +13:00
|
|
|
zint_add_test(gb2312, test_gb2312)
|
2020-05-06 12:33:56 +12:00
|
|
|
zint_add_test(gif, test_gif)
|
2019-11-29 08:15:29 +13:00
|
|
|
zint_add_test(gridmtx, test_gridmtx)
|
2019-10-17 22:06:21 +13:00
|
|
|
zint_add_test(gs1, test_gs1)
|
2019-12-09 05:15:34 +13:00
|
|
|
zint_add_test(hanxin, test_hanxin)
|
2019-09-02 08:09:47 +12:00
|
|
|
zint_add_test(imail, test_imail)
|
2021-01-19 09:10:52 +13:00
|
|
|
zint_add_test(iso3166, test_iso3166)
|
|
|
|
zint_add_test(iso4217, test_iso4217)
|
2021-01-12 07:11:41 +13:00
|
|
|
zint_add_test(ksx1001, test_ksx1001)
|
2020-06-15 01:42:40 +12:00
|
|
|
zint_add_test(large, test_large)
|
2019-10-17 22:06:21 +13:00
|
|
|
zint_add_test(library, test_library)
|
2019-09-02 08:09:47 +12:00
|
|
|
zint_add_test(mailmark, test_mailmark)
|
|
|
|
zint_add_test(maxicode, test_maxicode)
|
2020-06-05 05:45:25 +12:00
|
|
|
zint_add_test(medical, test_medical)
|
2020-04-07 08:26:13 +12:00
|
|
|
zint_add_test(pcx, test_pcx)
|
2019-12-20 09:29:11 +13:00
|
|
|
zint_add_test(pdf417, test_pdf417)
|
2020-06-05 05:45:25 +12:00
|
|
|
zint_add_test(plessey, test_plessey)
|
2021-03-09 01:34:34 +13:00
|
|
|
if(PNG_FOUND)
|
2020-04-04 07:40:59 +13:00
|
|
|
zint_add_test(png, test_png)
|
2021-03-09 01:34:34 +13:00
|
|
|
endif()
|
2019-10-14 21:49:15 +13:00
|
|
|
zint_add_test(postal, test_postal)
|
2020-04-05 03:53:29 +12:00
|
|
|
zint_add_test(print, test_print)
|
2020-08-13 09:16:11 +12:00
|
|
|
zint_add_test(ps, test_ps)
|
2019-09-02 22:43:14 +12:00
|
|
|
zint_add_test(qr, test_qr)
|
2019-11-12 10:38:21 +13:00
|
|
|
zint_add_test(raster, test_raster)
|
2020-11-28 01:54:44 +13:00
|
|
|
zint_add_test(reedsol, test_reedsol)
|
2019-09-02 08:09:47 +12:00
|
|
|
zint_add_test(rss, test_rss)
|
2019-11-28 05:16:14 +13:00
|
|
|
zint_add_test(sjis, test_sjis)
|
2020-04-04 07:40:59 +13:00
|
|
|
zint_add_test(svg, test_svg)
|
2020-03-27 03:22:27 +13:00
|
|
|
zint_add_test(telepen, test_telepen)
|
2020-05-07 06:57:27 +12:00
|
|
|
zint_add_test(tif, test_tif)
|
2020-04-10 09:08:54 +12:00
|
|
|
zint_add_test(ultra, test_ultra)
|
2019-09-02 08:09:47 +12:00
|
|
|
zint_add_test(upcean, test_upcean)
|
2019-11-12 10:38:21 +13:00
|
|
|
zint_add_test(vector, test_vector)
|