2020-04-06 23:26:13 +03:00
# Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
2019-09-01 23:09:47 +03:00
# Adapted from qrencode/tests/CMakeLists.txt
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
2020-06-14 16:42:40 +03:00
# vim: set ts=4 sw=4 et :
2019-09-01 23:09:47 +03:00
2020-05-06 00:28:25 +03:00
cmake_minimum_required ( VERSION 3.9 )
2019-09-01 23:09:47 +03:00
enable_testing ( )
2020-05-06 00:28:25 +03:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_SOURCE_DIR}/cmake/Modules/" )
2019-09-01 23:09:47 +03: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 03:37:55 +03:00
set ( ZINT_TEST FALSE CACHE BOOL "Set test compile flag" )
2019-09-01 23:09:47 +03:00
2020-05-06 00:28:25 +03:00
find_package ( LibZint 2.7.1 REQUIRED )
2019-10-14 11:49:15 +03:00
find_package ( PNG )
2020-05-06 00:28:25 +03:00
if ( PNG_FOUND )
2019-10-14 11:49:15 +03:00
include_directories ( ${ PNG_INCLUDES } )
2020-05-06 00:28:25 +03:00
else ( )
2019-10-14 11:49:15 +03:00
add_definitions ( -DNO_PNG )
2020-05-06 00:28:25 +03:00
endif ( )
2019-09-01 23:09:47 +03:00
2020-07-10 21:39:32 +03: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 }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t o o l s )
endif ( )
2020-05-06 00:28:25 +03:00
if ( ${ CMAKE_CXX_COMPILER_ID } STREQUAL "GNU" )
if ( ZINT_DEBUG )
2019-09-01 23:09:47 +03:00
add_compile_options ( "-g" )
2020-05-06 00:28:25 +03:00
endif ( )
if ( ZINT_SANITIZE )
2019-09-01 23:09:47 +03:00
add_compile_options ( "-fsanitize=undefined" )
add_compile_options ( "-fsanitize=address" )
2020-05-06 00:28:25 +03:00
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address" )
endif ( )
if ( ZINT_TEST )
2019-12-19 03:37:55 +03:00
add_definitions ( "-DZINT_TEST" )
2020-05-06 00:28:25 +03:00
endif ( )
endif ( )
2019-09-01 23:09:47 +03:00
2020-06-14 16:42:40 +03:00
add_library ( testcommon testcommon.c testcommon.h )
2020-05-06 00:28:25 +03:00
if ( PNG_FOUND )
2019-10-14 11:49:15 +03:00
target_link_libraries ( testcommon ZINT::ZINT ${ PNG_LIBRARIES } )
2020-05-06 00:28:25 +03:00
else ( )
2019-10-14 11:49:15 +03:00
target_link_libraries ( testcommon ZINT::ZINT )
2020-05-06 00:28:25 +03:00
endif ( )
2019-09-01 23:09:47 +03: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-14 16:42:40 +03:00
endmacro ( )
2019-09-01 23:09:47 +03:00
2020-06-04 20:45:25 +03:00
zint_add_test ( 2of5, test_2of5 )
2020-03-25 18:40:13 +03:00
zint_add_test ( auspost, test_auspost )
2020-03-29 01:50:55 +03:00
zint_add_test ( aztec, test_aztec )
2020-06-04 20:45:25 +03:00
zint_add_test ( bmp, test_bmp )
2019-09-01 23:09:47 +03:00
zint_add_test ( channel, test_channel )
2020-03-25 22:27:34 +03:00
zint_add_test ( codablock, test_codablock )
2020-06-04 20:45:25 +03:00
zint_add_test ( code, test_code )
2020-03-28 13:13:06 +03:00
zint_add_test ( code1, test_code1 )
2020-04-02 23:55:58 +03:00
zint_add_test ( code128, test_code128 )
2020-05-21 20:22:28 +03:00
zint_add_test ( code16k, test_code16k )
zint_add_test ( code49, test_code49 )
2019-11-27 19:16:14 +03:00
zint_add_test ( common, test_common )
2019-10-15 00:20:16 +03:00
zint_add_test ( composite, test_composite )
2019-11-27 19:16:14 +03:00
zint_add_test ( dmatrix, test_dmatrix )
2020-03-26 01:31:59 +03:00
zint_add_test ( dotcode, test_dotcode )
2019-09-01 23:09:47 +03:00
zint_add_test ( eci, test_eci )
2020-05-06 00:51:04 +03:00
zint_add_test ( emf, test_emf )
2019-12-08 19:15:34 +03:00
zint_add_test ( gb18030, test_gb18030 )
2019-11-28 22:15:29 +03:00
zint_add_test ( gb2312, test_gb2312 )
2020-05-06 03:33:56 +03:00
zint_add_test ( gif, test_gif )
2019-11-28 22:15:29 +03:00
zint_add_test ( gridmtx, test_gridmtx )
2019-10-17 12:06:21 +03:00
zint_add_test ( gs1, test_gs1 )
2019-12-08 19:15:34 +03:00
zint_add_test ( hanxin, test_hanxin )
2019-09-01 23:09:47 +03:00
zint_add_test ( imail, test_imail )
2020-06-14 16:42:40 +03:00
zint_add_test ( large, test_large )
2019-10-17 12:06:21 +03:00
zint_add_test ( library, test_library )
2019-09-01 23:09:47 +03:00
zint_add_test ( mailmark, test_mailmark )
zint_add_test ( maxicode, test_maxicode )
2020-06-04 20:45:25 +03:00
zint_add_test ( medical, test_medical )
2020-04-06 23:26:13 +03:00
zint_add_test ( pcx, test_pcx )
2019-12-19 23:29:11 +03:00
zint_add_test ( pdf417, test_pdf417 )
2020-06-04 20:45:25 +03:00
zint_add_test ( plessey, test_plessey )
2020-04-03 21:40:59 +03:00
zint_add_test ( png, test_png )
2019-10-14 11:49:15 +03:00
zint_add_test ( postal, test_postal )
2020-04-04 18:53:29 +03:00
zint_add_test ( print, test_print )
2019-09-02 13:43:14 +03:00
zint_add_test ( qr, test_qr )
2019-11-12 00:38:21 +03:00
zint_add_test ( raster, test_raster )
2019-09-01 23:09:47 +03:00
zint_add_test ( rss, test_rss )
2019-11-27 19:16:14 +03:00
zint_add_test ( sjis, test_sjis )
2020-04-03 21:40:59 +03:00
zint_add_test ( svg, test_svg )
2020-03-26 17:22:27 +03:00
zint_add_test ( telepen, test_telepen )
2020-05-06 21:57:27 +03:00
zint_add_test ( tif, test_tif )
2020-04-10 00:08:54 +03:00
zint_add_test ( ultra, test_ultra )
2019-09-01 23:09:47 +03:00
zint_add_test ( upcean, test_upcean )
2019-11-12 00:38:21 +03:00
zint_add_test ( vector, test_vector )