diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index a7a0d42d..50178d28 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2019 - 2020 Robin Stuart +# Copyright (C) 2019 - 2021 Robin Stuart # Adapted from qrencode/tests/CMakeLists.txt # Copyright (C) 2006-2017 Kentaro Fukuchi # vim: set ts=4 sw=4 et : @@ -17,9 +17,7 @@ set(ZINT_TEST FALSE CACHE BOOL "Set test compile flag") find_package(LibZint REQUIRED) find_package(PNG) -if(PNG_FOUND) - include_directories(${PNG_INCLUDES}) -else() +if(NOT PNG_FOUND) add_definitions(-DNO_PNG) endif() @@ -65,7 +63,7 @@ endif() add_library(testcommon testcommon.c testcommon.h) if(PNG_FOUND) - target_link_libraries(testcommon ZINT::ZINT ${PNG_LIBRARIES}) + target_link_libraries(testcommon ZINT::ZINT PNG::PNG) else() target_link_libraries(testcommon ZINT::ZINT) endif() @@ -113,7 +111,9 @@ zint_add_test(medical, test_medical) zint_add_test(pcx, test_pcx) zint_add_test(pdf417, test_pdf417) zint_add_test(plessey, test_plessey) +if(PNG_FOUND) zint_add_test(png, test_png) +endif() zint_add_test(postal, test_postal) zint_add_test(print, test_print) zint_add_test(ps, test_ps) diff --git a/backend/tests/test_print.c b/backend/tests/test_print.c index ca20bc18..b009f718 100644 --- a/backend/tests/test_print.c +++ b/backend/tests/test_print.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -90,6 +90,9 @@ static void test_print(int index, int generate, int debug) { } for (int j = 0; j < exts_len; j++) { +#ifdef NO_PNG + if (strcmp(exts[j], "png") == 0) continue; +#endif strcpy(data_dir, "../data/print/"); strcat(data_dir, exts[j]); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 73456e8c..3f334a04 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -40,6 +40,7 @@ #include #include #endif +#include #include #include