Add support for building with mingw-w64 GCC. Fix warnings

This commit is contained in:
Alexey Pavlov
2022-03-12 20:51:21 +03:00
committed by Jakub Melka
parent 2c5aca7ea6
commit d4ee4b890b
41 changed files with 174 additions and 113 deletions

View File

@@ -20,7 +20,8 @@ QT += gui widgets xml
TARGET = Pdf4QtLib
TEMPLATE = lib
win32:TARGET_EXT = .dll
include(../Pdf4Qt.pri)
VERSION = 1.1.0
QMAKE_TARGET_DESCRIPTION = "PDF rendering / editing library for Qt"
@@ -205,46 +206,56 @@ CONFIG(debug, debug|release) {
SUFFIX = d
}
# Link to freetype library
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/FreeType/ -lfreetype$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/FreeType/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/FreeType/include
win32-msvc*: {
# Link to freetype library
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/FreeType/ -lfreetype$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/FreeType/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/FreeType/include
# Link to OpenJPEG library
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/OpenJPEG/lib/ -lopenjp2$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/OpenJPEG/include/openjpeg-2.3
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/OpenJPEG/include/openjpeg-2.3
DEFINES += OPJ_STATIC
# Link to OpenJPEG library
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/OpenJPEG/lib/ -lopenjp2$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/OpenJPEG/include/openjpeg-2.3
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/OpenJPEG/include/openjpeg-2.3
DEFINES += OPJ_STATIC
# Link to Independent JPEG Groups libjpeg
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/libjpeg/bin/ -ljpeg$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/libjpeg/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/libjpeg/include
# Link to Independent JPEG Groups libjpeg
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/libjpeg/bin/ -ljpeg$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/libjpeg/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/libjpeg/include
# Link OpenSSL
LIBS += -L$$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/bin -L$$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/lib -llibcrypto -llibssl
INCLUDEPATH += $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/include
DEPENDPATH += $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/include
# Link OpenSSL
LIBS += -L$$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/bin -L$$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/lib -llibcrypto -llibssl
INCLUDEPATH += $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/include
DEPENDPATH += $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/include
# Add OpenSSL to installations
openssl_lib.files = $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/bin/libcrypto-1_1-x64.dll $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/bin/libssl-1_1-x64.dll
openssl_lib.path = $$DESTDIR/install
INSTALLS += openssl_lib
# Add OpenSSL to installations
openssl_lib.files = $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/bin/libcrypto-1_1-x64.dll $$Pdf4Qt_OPENSSL_PATH/OpenSSL/Win_x64/bin/libssl-1_1-x64.dll
openssl_lib.path = $$DESTDIR/install
INSTALLS += openssl_lib
# Link zlib
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/zlib/bin/ -lzlibstatic$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/zlib/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/zlib/include
# Link zlib
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/zlib/bin/ -lzlibstatic$${SUFFIX}
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/zlib/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/zlib/include
# Link lcms2
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/lcms2/bin$${SUFFIX}/ -llcms2_static
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/lcms2/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/lcms2/include
# Link lcms2
LIBS += -L$$Pdf4Qt_DEPENDENCIES_PATH/lcms2/bin$${SUFFIX}/ -llcms2_static
INCLUDEPATH += $$Pdf4Qt_DEPENDENCIES_PATH/lcms2/include
DEPENDPATH += $$Pdf4Qt_DEPENDENCIES_PATH/lcms2/include
}
win32-*g++|unix: {
PKGCONFIG += freetype2 libopenjp2 libjpeg lcms2 libssl libcrypto zlib
LIBS += -ltbb
win32: {
LIBS += -lmscms -lcrypt32 -lsecur32
}
}
# ensure debug info even for RELEASE build
CONFIG += force_debug_info
QMAKE_CXXFLAGS += /std:c++latest /utf-8 /bigobj
QMAKE_RESOURCE_FLAGS += -threshold 0 -compress 9
PdfforQt_library.files = $$DESTDIR/Pdf4QtLib.dll

View File

@@ -1415,7 +1415,7 @@ void PDFAnnotationManager::drawAnnotation(const PageAnnotation& annotation,
{
errors.push_back(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
}
catch (PDFRendererException exception)
catch (const PDFRendererException &exception)
{
errors.push_back(exception.getError());
}

View File

@@ -293,7 +293,7 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
fillRGBBuffer(inputColors, outputLine, intent, cms, reporter);
}
catch (PDFException lineException)
catch (const PDFException &lineException)
{
QMutexLocker lock(&exceptionMutex);
if (!exception)
@@ -396,7 +396,7 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
*outputLine++ = *alphaLine++;
}
}
catch (PDFException lineException)
catch (const PDFException &lineException)
{
QMutexLocker lock(&exceptionMutex);
if (!exception)

View File

@@ -585,7 +585,7 @@ PDFDocument PDFDocumentReader::readFromBuffer(const QByteArray& buffer)
PDFObjectStorage storage(std::move(objects), PDFObject(xrefTable.getTrailerDictionary()), qMove(m_securityHandler));
return PDFDocument(std::move(storage), m_version);
}
catch (PDFException parserException)
catch (const PDFException &parserException)
{
m_result = Result::Failed;
m_errorMessage = parserException.getMessage();
@@ -770,7 +770,7 @@ PDFDocument PDFDocumentReader::readDamagedDocumentFromBuffer(const QByteArray& b
PDFObjectStorage storage(std::move(objects), PDFObject(trailerDictionaryObject), qMove(m_securityHandler));
return PDFDocument(std::move(storage), m_version);
}
catch (PDFException parserException)
catch (const PDFException &parserException)
{
m_result = Result::Failed;
m_warnings << parserException.getMessage();

View File

@@ -548,9 +548,9 @@ private:
void PDFStructureTreeTextFlowCollector::visitStructureTree(const PDFStructureTree* structureTree)
{
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemStart});
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemStart, {} });
acceptChildren(structureTree);
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemEnd});
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemEnd, {} });
}
void PDFStructureTreeTextFlowCollector::markHasContent()
@@ -564,7 +564,7 @@ void PDFStructureTreeTextFlowCollector::markHasContent()
void PDFStructureTreeTextFlowCollector::visitStructureElement(const PDFStructureElement* structureElement)
{
size_t index = m_items->size();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemStart});
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemStart, {} });
// Mark stack so we can delete unused items
m_hasContentStack.push_back(false);
@@ -579,37 +579,37 @@ void PDFStructureTreeTextFlowCollector::visitStructureElement(const PDFStructure
if (!title.isEmpty())
{
markHasContent();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureTitle});
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureTitle, {} });
}
if (!language.isEmpty())
{
markHasContent();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, language, PDFDocumentTextFlow::StructureLanguage });
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, language, PDFDocumentTextFlow::StructureLanguage, {} });
}
if (!alternativeDescription.isEmpty())
{
markHasContent();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, alternativeDescription, PDFDocumentTextFlow::StructureAlternativeDescription });
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, alternativeDescription, PDFDocumentTextFlow::StructureAlternativeDescription, {} });
}
if (!expandedForm.isEmpty())
{
markHasContent();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, expandedForm, PDFDocumentTextFlow::StructureExpandedForm });
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, expandedForm, PDFDocumentTextFlow::StructureExpandedForm, {} });
}
if (!actualText.isEmpty())
{
markHasContent();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, actualText, PDFDocumentTextFlow::StructureActualText });
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, actualText, PDFDocumentTextFlow::StructureActualText, {} });
}
if (!phoneme.isEmpty())
{
markHasContent();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, phoneme, PDFDocumentTextFlow::StructurePhoneme });
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, phoneme, PDFDocumentTextFlow::StructurePhoneme, {} });
}
for (const auto& textItem : m_extractor->getText(structureElement))
@@ -623,7 +623,7 @@ void PDFStructureTreeTextFlowCollector::visitStructureElement(const PDFStructure
const bool hasContent = m_hasContentStack.back();
m_hasContentStack.pop_back();
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemEnd });
m_items->push_back(PDFDocumentTextFlow::Item{ QRectF(), -1, QString(), PDFDocumentTextFlow::StructureItemEnd, {} });
if (!hasContent)
{
@@ -702,12 +702,12 @@ PDFDocumentTextFlow PDFDocumentTextFlowFactory::create(const PDFDocument* docume
PDFTextFlows textFlows = PDFTextFlow::createTextFlows(textLayout, PDFTextFlow::FlowFlags(PDFTextFlow::SeparateBlocks) | PDFTextFlow::RemoveSoftHyphen, pageIndex);
PDFDocumentTextFlow::Items flowItems;
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, PDFTranslationContext::tr("Page %1").arg(pageIndex + 1), PDFDocumentTextFlow::PageStart });
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, PDFTranslationContext::tr("Page %1").arg(pageIndex + 1), PDFDocumentTextFlow::PageStart, {} });
for (const PDFTextFlow& textFlow : textFlows)
{
flowItems.emplace_back(PDFDocumentTextFlow::Item{ textFlow.getBoundingBox(), pageIndex, textFlow.getText(), PDFDocumentTextFlow::Text, textFlow.getBoundingBoxes() });
}
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, QString(), PDFDocumentTextFlow::PageEnd });
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, QString(), PDFDocumentTextFlow::PageEnd, {} });
QMutexLocker lock(&mutex);
items[pageIndex] = qMove(flowItems);
@@ -760,7 +760,7 @@ PDFDocumentTextFlow PDFDocumentTextFlowFactory::create(const PDFDocument* docume
PDFDocumentTextFlow::Items flowItems;
for (PDFInteger pageIndex : pageIndices)
{
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, PDFTranslationContext::tr("Page %1").arg(pageIndex + 1), PDFDocumentTextFlow::PageStart });
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, PDFTranslationContext::tr("Page %1").arg(pageIndex + 1), PDFDocumentTextFlow::PageStart, {} });
for (const PDFStructureTreeTextItem& sequenceItem : extractor.getTextSequence(pageIndex))
{
if (sequenceItem.type == PDFStructureTreeTextItem::Type::Text)
@@ -768,7 +768,7 @@ PDFDocumentTextFlow PDFDocumentTextFlowFactory::create(const PDFDocument* docume
flowItems.emplace_back(PDFDocumentTextFlow::Item{ sequenceItem.boundingRect, pageIndex, sequenceItem.text, PDFDocumentTextFlow::Text, sequenceItem.characterBoundingRects });
}
}
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, QString(), PDFDocumentTextFlow::PageEnd });
flowItems.emplace_back(PDFDocumentTextFlow::Item{ QRectF(), pageIndex, QString(), PDFDocumentTextFlow::PageEnd, {} });
}
result = PDFDocumentTextFlow(qMove(flowItems));

View File

@@ -707,7 +707,7 @@ void PDFPageContentProcessor::processContent(const QByteArray& content)
m_operands.clear();
m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
}
catch (PDFRendererException exception)
catch (const PDFRendererException &exception)
{
m_operands.clear();
m_errorList.append(exception.getError());
@@ -3401,7 +3401,7 @@ bool PDFPageContentProcessor::isContentSuppressedByOC(PDFObjectReference ocgOrOc
{
ocmd = PDFOptionalContentMembershipObject::create(m_document, PDFObject::createReference(ocgOrOcmd));
}
catch (PDFException e)
catch (const PDFException &e)
{
m_errorList.push_back(PDFRenderError(RenderErrorType::Error, e.getMessage()));
}

View File

@@ -700,7 +700,7 @@ protected:
/// Returns optional content activity
const PDFOptionalContentActivity* getOptionalContentActivity() const { return m_optionalContentActivity; }
class PDFTransparencyGroupGuard
class PDF4QTLIBSHARED_EXPORT PDFTransparencyGroupGuard
{
public:
explicit PDFTransparencyGroupGuard(PDFPageContentProcessor* processor, PDFTransparencyGroup&& group);

View File

@@ -246,7 +246,7 @@ std::vector<PDFDependentLibraryInfo> PDFDependentLibraryInfo::getLibraryInfo()
libjpegInfo.library = tr("libjpeg");
libjpegInfo.license = tr("permissive + ack.");
libjpegInfo.url = tr("https://www.ijg.org/");
#if defined(Q_OS_UNIX)
#if defined(Q_OS_UNIX) || defined(__MINGW32__)
libjpegInfo.version = tr("%1").arg(JPEG_LIB_VERSION);
#else
libjpegInfo.version = tr("%1.%2").arg(JPEG_LIB_VERSION_MAJOR).arg(JPEG_LIB_VERSION_MINOR);