#220 backend/tests cmake: Use PNG::PNG for libpng (cf #213), props Schaich Alonso

This commit is contained in:
gitlost 2021-03-08 12:34:34 +00:00
parent 6b7b5109b9
commit d81b5db271
3 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com> # Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
# Adapted from qrencode/tests/CMakeLists.txt # Adapted from qrencode/tests/CMakeLists.txt
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org> # Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
# vim: set ts=4 sw=4 et : # 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(LibZint REQUIRED)
find_package(PNG) find_package(PNG)
if(PNG_FOUND) if(NOT PNG_FOUND)
include_directories(${PNG_INCLUDES})
else()
add_definitions(-DNO_PNG) add_definitions(-DNO_PNG)
endif() endif()
@ -65,7 +63,7 @@ endif()
add_library(testcommon testcommon.c testcommon.h) add_library(testcommon testcommon.c testcommon.h)
if(PNG_FOUND) if(PNG_FOUND)
target_link_libraries(testcommon ZINT::ZINT ${PNG_LIBRARIES}) target_link_libraries(testcommon ZINT::ZINT PNG::PNG)
else() else()
target_link_libraries(testcommon ZINT::ZINT) target_link_libraries(testcommon ZINT::ZINT)
endif() endif()
@ -113,7 +111,9 @@ zint_add_test(medical, test_medical)
zint_add_test(pcx, test_pcx) zint_add_test(pcx, test_pcx)
zint_add_test(pdf417, test_pdf417) zint_add_test(pdf417, test_pdf417)
zint_add_test(plessey, test_plessey) zint_add_test(plessey, test_plessey)
if(PNG_FOUND)
zint_add_test(png, test_png) zint_add_test(png, test_png)
endif()
zint_add_test(postal, test_postal) zint_add_test(postal, test_postal)
zint_add_test(print, test_print) zint_add_test(print, test_print)
zint_add_test(ps, test_ps) zint_add_test(ps, test_ps)

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions 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++) { for (int j = 0; j < exts_len; j++) {
#ifdef NO_PNG
if (strcmp(exts[j], "png") == 0) continue;
#endif
strcpy(data_dir, "../data/print/"); strcpy(data_dir, "../data/print/");
strcat(data_dir, exts[j]); strcat(data_dir, exts[j]);

View File

@ -40,6 +40,7 @@
#include <zlib.h> #include <zlib.h>
#include <setjmp.h> #include <setjmp.h>
#endif #endif
#include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>