Skip to content

Commit

Permalink
Allow linking against system libraries via pkg-config
Browse files Browse the repository at this point in the history
When 'link_pkgconfig' is added to CONFIG, chessx will now use pkg-config
to dynamically link against the quazip and zlib libraries installed on
the system, rather than bundling quazip or guessing the header file
location. Default behavior remains unchanged.

Signed-off-by: Ondrej Mosnáček <[email protected]>
  • Loading branch information
WOnder93 committed Feb 1, 2023
1 parent a2b8b1d commit 7ef6fc8
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 51 deletions.
102 changes: 53 additions & 49 deletions chessx.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ sound {
QT += multimedia
}

DEFINES += QUAZIP_STATIC
DEFINES += QT_NO_CAST_TO_ASCII
DEFINES *= QT_USE_QSTRINGBUILDER

Expand Down Expand Up @@ -83,6 +82,57 @@ unix|!macx {
binfiles.path = $$BINDIR
}

link_pkgconfig {
PKGCONFIG += quazip1-qt5 zlib
}
else {
HEADERS += \
src/quazip/JlCompress.h \
src/quazip/crypt.h \
src/quazip/ioapi.h \
src/quazip/quaadler32.h \
src/quazip/quachecksum32.h \
src/quazip/quacrc32.h \
src/quazip/quagzipfile.h \
src/quazip/quaziodevice.h \
src/quazip/quazip.h \
src/quazip/quazip_global.h \
src/quazip/quazipdir.h \
src/quazip/quazipfile.h \
src/quazip/quazipfileinfo.h \
src/quazip/quazipnewinfo.h \
src/quazip/unzip.h \
src/quazip/zip.h

SOURCES += \
src/quazip/JlCompress.cpp \
src/quazip/qioapi.cpp \
src/quazip/quaadler32.cpp \
src/quazip/quacrc32.cpp \
src/quazip/quagzipfile.cpp \
src/quazip/quaziodevice.cpp \
src/quazip/quazip.cpp \
src/quazip/quazipdir.cpp \
src/quazip/quazipfile.cpp \
src/quazip/quazipnewinfo.cpp \
src/quazip/unzip.cpp \
src/quazip/zip.cpp

INCLUDEPATH += src/quazip
DEFINES += QUAZIP_STATIC

INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib
win32 {
# DEFINES += ZLIB_WINAPI
# LIBS += -lz
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib
win32-g++:LIBS += -lz
}
else {
LIBS += -lz
}
}

scid {
# Scid sources
HEADERS += \
Expand Down Expand Up @@ -336,23 +386,7 @@ HEADERS += src/database/board.h \
src/gui/textbrowserex.h \
src/gui/textedit.h \
src/gui/toolmainwindow.h \
src/gui/translatingslider.h \
src/quazip/JlCompress.h \
src/quazip/crypt.h \
src/quazip/ioapi.h \
src/quazip/quaadler32.h \
src/quazip/quachecksum32.h \
src/quazip/quacrc32.h \
src/quazip/quagzipfile.h \
src/quazip/quaziodevice.h \
src/quazip/quazip.h \
src/quazip/quazip_global.h \
src/quazip/quazipdir.h \
src/quazip/quazipfile.h \
src/quazip/quazipfileinfo.h \
src/quazip/quazipnewinfo.h \
src/quazip/unzip.h \
src/quazip/zip.h
src/gui/translatingslider.h

SOURCES += \
src/database/analysis.cpp \
Expand Down Expand Up @@ -504,34 +538,13 @@ SOURCES += \
src/gui/testadapter.cpp \
src/gui/textedit.cpp \
src/gui/toolmainwindow.cpp \
src/gui/translatingslider.cpp \
src/quazip/JlCompress.cpp \
src/quazip/qioapi.cpp \
src/quazip/quaadler32.cpp \
src/quazip/quacrc32.cpp \
src/quazip/quagzipfile.cpp \
src/quazip/quaziodevice.cpp \
src/quazip/quazip.cpp \
src/quazip/quazipdir.cpp \
src/quazip/quazipfile.cpp \
src/quazip/quazipnewinfo.cpp \
src/quazip/unzip.cpp \
src/quazip/zip.cpp
src/gui/translatingslider.cpp

TEMPLATE = app
INCLUDEPATH += src/database
INCLUDEPATH += src/guess
INCLUDEPATH += src/gui
INCLUDEPATH += src/dialogs
INCLUDEPATH += src/quazip
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib

win32 {
# DEFINES += ZLIB_WINAPI
# LIBS += -lz
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib
win32-g++:LIBS += -lz
}

UI_DIR = src/generated
MOC_DIR = src/generated
Expand All @@ -549,15 +562,6 @@ CONFIG(release, debug|release) {
DEFINES += QT_NO_DEBUG_OUTPUT NDEBUG
}

!win32 {
CONFIG(debug, debug|release) {
LIBS += -lz
}
CONFIG(release, debug|release) {
LIBS += -lz
}
}

TARGET = chessx

ICON = data/images/chessx.icns
Expand Down
10 changes: 8 additions & 2 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#include "output.h"
#include "pgndatabase.h"
#include "playerlistwidget.h"
#include "quazip.h"
#include "quazipfile.h"
#include "savedialog.h"
#include "settings.h"
#include "style.h"
Expand All @@ -62,6 +60,14 @@
#include "translatingslider.h"
#include "version.h"

#ifdef QUAZIP_STATIC
#include "quazip.h"
#include "quazipfile.h"
#else
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#endif

#include <time.h>

#include <QApplication>
Expand Down

0 comments on commit 7ef6fc8

Please sign in to comment.