CMakeList/configBitstreamParser: add optional zlib-ng support. No zlibxx is required

This commit is contained in:
Gwenhael Goavec-Merou 2021-12-02 07:20:58 +01:00
parent bfef127d9e
commit 9005b2880b
2 changed files with 19 additions and 1 deletions

View File

@ -37,11 +37,21 @@ if(USE_PKGCONFIG)
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
pkg_check_modules(HIDAPI hidapi-hidraw)
pkg_check_modules(ZLIB zlib)
# if hidraw not found try with libusb
if(NOT HIDAPI_FOUND)
pkg_check_modules(HIDAPI hidapi-libusb)
endif()
# zlib support (gzip)
pkg_check_modules(ZLIB zlib)
if (NOT ZLIB_FOUND)
# try zlib-ng
pkg_check_modules(ZLIB zlib-ng)
if (ZLIB_FOUND)
add_definitions(-DHAS_ZLIBNG)
else()
message(FATAL_ERROR "Could find ZLIB")
endif()
endif(NOT ZLIB_FOUND)
if(ENABLE_UDEV)
pkg_check_modules(LIBUDEV libudev)

View File

@ -11,8 +11,16 @@
#include <unistd.h>
#ifdef HAS_ZLIB
#ifdef HAS_ZLIBNG
#include <zlib-ng.h>
#define z_stream zng_stream
#define inflateInit2(_strm, _windowBits) zng_inflateInit2(_strm, _windowBits)
#define inflate(_strm, __flush) zng_inflate(_strm, __flush)
#define inflateEnd(_strm) zng_inflateEnd(_strm)
#else
#include <zlib.h>
#endif
#endif
#include "display.hpp"