Made zlib an optional dependency.
Only needed to read legacy files, which is not fully supported yet. Hopefully this will make it easier to build on Windows.
This commit is contained in:
+7
-2
@@ -48,11 +48,11 @@ if (MINGW)
|
||||
set (QT_BIN_DIR ${QT_BASE_DIR}/bin)
|
||||
endif ()
|
||||
|
||||
find_package (ZLIB 1.2 REQUIRED)
|
||||
|
||||
#
|
||||
# Optional dependencies
|
||||
#
|
||||
find_package (ZLIB 1.2 QUIET)
|
||||
find_package (GnuBarcode 0.98 QUIET)
|
||||
find_package (LibQrencode 3.4 QUIET)
|
||||
find_package (LibZint 2.6 QUIET)
|
||||
@@ -91,7 +91,12 @@ message (STATUS "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX})
|
||||
message (STATUS "Source code location .... " ${glabels_SOURCE_DIR})
|
||||
message (STATUS "C++ Compiler ............ " ${CMAKE_CXX_COMPILER_ID} " " ${CMAKE_CXX_COMPILER} " " ${CMAKE_CXX_COMPILER_VERSION})
|
||||
message (STATUS "Qt version .............. " ${Qt5Core_VERSION})
|
||||
message (STATUS "zlib version ............ " ${ZLIB_VERSION_STRING})
|
||||
|
||||
if (ZLIB_FOUND)
|
||||
message (STATUS "zlib (optional).......... " ${ZLIB_VERSION_STRING})
|
||||
else (ZLIB_FOUND)
|
||||
message (STATUS "zlib (optional).......... No.")
|
||||
endif (ZLIB_FOUND)
|
||||
|
||||
if (GNUBARCODE_FOUND)
|
||||
message (STATUS "GNU Barcode (optional)... " ${GNUBARCODE_VERSION_STRING})
|
||||
|
||||
+11
-1
@@ -1,5 +1,15 @@
|
||||
project (Model LANGUAGES CXX)
|
||||
|
||||
#=======================================
|
||||
# Handle optional dependencies
|
||||
#=======================================
|
||||
if (${ZLIB_FOUND})
|
||||
add_definitions (-DHAVE_ZLIB=1)
|
||||
set (OPTIONAL_ZLIB ZLIB::ZLIB)
|
||||
else ()
|
||||
set (OPTIONAL_ZLIB "")
|
||||
endif ()
|
||||
|
||||
#=======================================
|
||||
# Sources
|
||||
#=======================================
|
||||
@@ -96,7 +106,7 @@ target_link_libraries (Model
|
||||
Qt5::PrintSupport
|
||||
Qt5::Xml
|
||||
Qt5::Svg
|
||||
ZLIB::ZLIB
|
||||
${OPTIONAL_ZLIB}
|
||||
)
|
||||
|
||||
#=======================================
|
||||
|
||||
@@ -41,8 +41,9 @@
|
||||
#include <QTextDocument>
|
||||
#include <QtDebug>
|
||||
|
||||
#if HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace glabels
|
||||
{
|
||||
@@ -70,10 +71,15 @@ namespace glabels
|
||||
QByteArray rawData = file.readAll();
|
||||
if ( ((rawData[0]&0xFF) == 0x1F) && ((rawData[1]&0xFF) == 0x8b) ) // gzip magic number 0x1F, 0x8B
|
||||
{
|
||||
#if HAVE_ZLIB
|
||||
// gzip compressed format
|
||||
QByteArray unzippedData;
|
||||
gunzip( rawData, unzippedData );
|
||||
success = doc.setContent( unzippedData, false, &errorString, &errorLine, &errorColumn );
|
||||
#else
|
||||
qWarning() << "Warning: Cannot read compressed glabels project file! gLabels not build with ZLIB.";
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,6 +181,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_ZLIB
|
||||
void
|
||||
XmlLabelParser::gunzip( const QByteArray& data, QByteArray& result )
|
||||
{
|
||||
@@ -223,6 +230,7 @@ namespace glabels
|
||||
// clean up
|
||||
inflateEnd(&strm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Model*
|
||||
|
||||
Reference in New Issue
Block a user