From 0a7b4e3eb8544ec662a571b5533e9b55913fe732 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 10 Jan 2018 17:38:48 +0200 Subject: [qt] Fix import/export symbols declarations Fixes #10875 --- platform/qt/config.qdocconf | 2 +- platform/qt/include/qmapbox.hpp | 24 +++++++++++++++--------- platform/qt/include/qmapboxgl.hpp | 6 +++--- platform/qt/qt.cmake | 4 ++++ platform/qt/src/qmapbox.cpp | 6 +++--- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/platform/qt/config.qdocconf b/platform/qt/config.qdocconf index b8ade81bb2..d6f0edbd32 100644 --- a/platform/qt/config.qdocconf +++ b/platform/qt/config.qdocconf @@ -4,7 +4,7 @@ include($QT_INSTALL_DOCS/global/compat.qdocconf) include($QT_INSTALL_DOCS/global/fileextensions.qdocconf) include($QT_INSTALL_DOCS/global/qt-html-templates-online.qdocconf) -Cpp.ignoretokens = Q_DECL_EXPORT +Cpp.ignoretokens = Q_MAPBOXGL_EXPORT project = QMapboxGL description = Mapbox Qt SDK diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp index 2bb5d8705c..5a5198108c 100644 --- a/platform/qt/include/qmapbox.hpp +++ b/platform/qt/include/qmapbox.hpp @@ -9,6 +9,12 @@ // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style +#if defined(QT_BUILD_MAPBOXGL_LIB) + #define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT +#else + #define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT +#endif + namespace QMapbox { typedef QPair Coordinate; @@ -20,7 +26,7 @@ typedef QList CoordinatesCollection; typedef QList CoordinatesCollections; -struct Q_DECL_EXPORT Feature { +struct Q_MAPBOXGL_EXPORT Feature { enum Type { PointType = 1, LineStringType, @@ -38,7 +44,7 @@ struct Q_DECL_EXPORT Feature { QVariant id; }; -struct Q_DECL_EXPORT ShapeAnnotationGeometry { +struct Q_MAPBOXGL_EXPORT ShapeAnnotationGeometry { enum Type { LineStringType = 1, PolygonType, @@ -54,12 +60,12 @@ struct Q_DECL_EXPORT ShapeAnnotationGeometry { CoordinatesCollections geometry; }; -struct Q_DECL_EXPORT SymbolAnnotation { +struct Q_MAPBOXGL_EXPORT SymbolAnnotation { Coordinate geometry; QString icon; }; -struct Q_DECL_EXPORT LineAnnotation { +struct Q_MAPBOXGL_EXPORT LineAnnotation { /*! Class constructor. */ LineAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, float width_ = 1.0f, const QColor& color_ = Qt::black) @@ -71,7 +77,7 @@ struct Q_DECL_EXPORT LineAnnotation { QColor color; }; -struct Q_DECL_EXPORT FillAnnotation { +struct Q_MAPBOXGL_EXPORT FillAnnotation { /*! Class constructor. */ FillAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, const QColor& color_ = Qt::black, const QVariant& outlineColor_ = QVariant()) @@ -92,13 +98,13 @@ enum NetworkMode { Offline, }; -Q_DECL_EXPORT QList >& defaultStyles(); +Q_MAPBOXGL_EXPORT QList >& defaultStyles(); -Q_DECL_EXPORT NetworkMode networkMode(); -Q_DECL_EXPORT void setNetworkMode(NetworkMode); +Q_MAPBOXGL_EXPORT NetworkMode networkMode(); +Q_MAPBOXGL_EXPORT void setNetworkMode(NetworkMode); // This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters. -struct Q_DECL_EXPORT CustomLayerRenderParameters { +struct Q_MAPBOXGL_EXPORT CustomLayerRenderParameters { double width; double height; double latitude; diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index ebbd949921..8b319b0453 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -16,7 +16,7 @@ class QMapboxGLPrivate; // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style -class Q_DECL_EXPORT QMapboxGLSettings +class Q_MAPBOXGL_EXPORT QMapboxGLSettings { public: QMapboxGLSettings(); @@ -77,7 +77,7 @@ private: std::function m_resourceTransform; }; -struct Q_DECL_EXPORT QMapboxGLCameraOptions { +struct Q_MAPBOXGL_EXPORT QMapboxGLCameraOptions { QVariant center; // Coordinate QVariant anchor; // QPointF QVariant zoom; // double @@ -85,7 +85,7 @@ struct Q_DECL_EXPORT QMapboxGLCameraOptions { QVariant pitch; // double }; -class Q_DECL_EXPORT QMapboxGL : public QObject +class Q_MAPBOXGL_EXPORT QMapboxGL : public QObject { Q_OBJECT Q_PROPERTY(double latitude READ latitude WRITE setLatitude) diff --git a/platform/qt/qt.cmake b/platform/qt/qt.cmake index 3e81b17d00..aaae199650 100644 --- a/platform/qt/qt.cmake +++ b/platform/qt/qt.cmake @@ -70,6 +70,10 @@ target_include_directories(qmapboxgl PUBLIC platform/qt/include ) +target_compile_definitions(qmapboxgl + PRIVATE "-DQT_BUILD_MAPBOXGL_LIB" +) + target_link_libraries(qmapboxgl PRIVATE mbgl-core PRIVATE mbgl-filesource diff --git a/platform/qt/src/qmapbox.cpp b/platform/qt/src/qmapbox.cpp index aad32a35dc..ec76ebfe53 100644 --- a/platform/qt/src/qmapbox.cpp +++ b/platform/qt/src/qmapbox.cpp @@ -206,7 +206,7 @@ namespace QMapbox { Returns the current QMapbox::NetworkMode. */ -Q_DECL_EXPORT NetworkMode networkMode() +NetworkMode networkMode() { return static_cast(mbgl::NetworkStatus::Get()); } @@ -219,7 +219,7 @@ Q_DECL_EXPORT NetworkMode networkMode() File source requests uses the available network when \a mode is set to \b Online, otherwise scoped to the local cache. */ -Q_DECL_EXPORT void setNetworkMode(NetworkMode mode) +void setNetworkMode(NetworkMode mode) { mbgl::NetworkStatus::Set(static_cast(mode)); } @@ -230,7 +230,7 @@ Q_DECL_EXPORT void setNetworkMode(NetworkMode mode) Returns a list containing a pair of string objects, representing the style URL and name, respectively. */ -Q_DECL_EXPORT QList >& defaultStyles() +QList >& defaultStyles() { static QList> styles; -- cgit v1.2.1