diff --git a/qmsgpack.pri b/qmsgpack.pri index 026f721..f50e83c 100644 --- a/qmsgpack.pri +++ b/qmsgpack.pri @@ -7,10 +7,7 @@ SOURCES += \ $$PWD/src/msgpackcommon.cpp \ $$PWD/src/private/pack_p.cpp \ $$PWD/src/private/unpack_p.cpp \ - $$PWD/src/private/qt_types_p.cpp \ - $$PWD/src/msgpackstream.cpp \ - $$PWD/src/stream/time.cpp \ - $$PWD/src/stream/geometry.cpp + $$PWD/src/msgpackstream.cpp HEADERS += \ $$PWD/src/msgpack.h \ @@ -19,18 +16,27 @@ HEADERS += \ $$PWD/src/endianhelper.h \ $$PWD/src/msgpackcommon.h \ $$PWD/src/msgpack_export.h \ - $$PWD/src/private/qt_types_p.h \ - $$PWD/src/msgpackstream.h \ - $$PWD/src/stream/time.h \ - $$PWD/src/stream/geometry.h + $$PWD/src/msgpackstream.h -qtHaveModule(gui) { - QT += gui -} - -qtHaveModule(location) { - QT += location - - SOURCES += $$PWD/src/stream/location.cpp - HEADERS += $$PWD/src/stream/location.h +!contains(DEFINES, MSGPACK_NO_PACKTYPES) { + SOURCES += \ + $$PWD/src/private/qt_types_p.cpp \ + $$PWD/src/stream/time.cpp \ + $$PWD/src/stream/geometry.cpp + + HEADERS += \ + $$PWD/src/private/qt_types_p.h \ + $$PWD/src/stream/time.h \ + $$PWD/src/stream/geometry.h + + qtHaveModule(gui) { + QT += gui + } + + qtHaveModule(location) { + QT += location + + SOURCES += $$PWD/src/stream/location.cpp + HEADERS += $$PWD/src/stream/location.h + } } diff --git a/src/msgpack.cpp b/src/msgpack.cpp index f98a931..781d4a3 100644 --- a/src/msgpack.cpp +++ b/src/msgpack.cpp @@ -3,13 +3,16 @@ #include "msgpack.h" #include "private/unpack_p.h" #include "private/pack_p.h" -#include "private/qt_types_p.h" #include +#ifndef MSGPACK_NO_PACKTYPES +#include "private/qt_types_p.h" + #ifdef QT_LOCATION_LIB #include #endif +#endif // MSGPACK_NO_PACKTYPES QVariant MsgPack::unpack(const QByteArray &data) { @@ -51,6 +54,7 @@ qint8 MsgPack::msgpackType(int qType) bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType) { +#ifndef MSGPACK_NO_PACKTYPES switch (qType) { #ifdef QT_GUI_LIB case QMetaType::QColor: @@ -92,6 +96,9 @@ bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType) #endif // QT_LOCATION_LIB break; } +#else + Q_UNUSED(msgpackType) +#endif // MSGPACK_NO_PACKTYPES qWarning("qmsgpack was built without metatype %d support.", int(qType)); qWarning("Use MsgPack::registerPacker() and MsgPack::registerUnpacker() to register metatype %d manually.", int(qType)); diff --git a/src/src.pro b/src/src.pro index e81a138..8ae368d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -18,12 +18,14 @@ HEADERS_INSTALL = \ msgpack_export.h \ msgpackstream.h \ -STREAM_HEADERS_INSTALL = \ - stream/geometry.h \ - stream/time.h +!contains(DEFINES, MSGPACK_NO_PACKTYPES) { + STREAM_HEADERS_INSTALL = \ + stream/geometry.h \ + stream/time.h -qtHaveModule(location) { - STREAM_HEADERS_INSTALL += stream/location.h + qtHaveModule(location) { + STREAM_HEADERS_INSTALL += stream/location.h + } } unix { diff --git a/tests/tests.pro b/tests/tests.pro index 397bda5..ca76dd3 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -3,6 +3,10 @@ TEMPLATE = subdirs SUBDIRS += \ pack \ unpack \ - mixed \ - stream \ - qttypes + mixed + +!contains(DEFINES, MSGPACK_NO_PACKTYPES) { + SUBDIRS += \ + stream \ + qttypes +}