Skip to content

Commit

Permalink
Fix export with multiple libraries (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntadej authored Oct 29, 2023
1 parent a9d82d7 commit b8672ab
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 57 deletions.
5 changes: 3 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_subdirectory(
# Public headers
string(TOLOWER ${MLN_QT_NAME} MLN_QT_NAME_LOWERCASE)
set(Core_Headers
export.hpp
export_core.hpp
map.hpp
settings.hpp
types.hpp
Expand All @@ -27,6 +27,7 @@ foreach(Header ${Core_Headers})
string(TOUPPER ${HeaderFirstLetter} HeaderFirstLetter)
string(REGEX REPLACE "^.(.*)" "${HeaderFirstLetter}\\1" HeaderOut "${Header}")
string(REGEX REPLACE "\.hpp" "" HeaderOut "${HeaderOut}")
string(REPLACE "Export_core" "Export" HeaderOut "${HeaderOut}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}/${HeaderOut}" "#include \"${Header}\"")
list(APPEND Core_Headers_Generated "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}/${HeaderOut}")
endforeach()
Expand Down Expand Up @@ -84,7 +85,7 @@ endif()
target_compile_definitions(
Core
PRIVATE
QT_BUILD_MAPLIBRE_LIB
QT_BUILD_MAPLIBRE_CORE_LIB
)
# static?
# target_compile_definitions(
Expand Down
20 changes: 0 additions & 20 deletions src/core/export.hpp

This file was deleted.

20 changes: 20 additions & 0 deletions src/core/export_core.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2023 MapLibre contributors

// SPDX-License-Identifier: BSD-2-Clause

#ifndef QMAPLIBRE_CORE_EXPORT_H
#define QMAPLIBRE_CORE_EXPORT_H

#include <QtCore/QtGlobal>

#if !defined(QT_MAPLIBRE_STATIC)
#if defined(QT_BUILD_MAPLIBRE_CORE_LIB)
#define Q_MAPLIBRE_CORE_EXPORT Q_DECL_EXPORT
#else
#define Q_MAPLIBRE_CORE_EXPORT Q_DECL_IMPORT
#endif
#else
#define Q_MAPLIBRE_CORE_EXPORT
#endif

#endif // QMAPLIBRE_CORE_EXPORT_H
5 changes: 2 additions & 3 deletions src/core/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef QMAPLIBRE_MAP_H
#define QMAPLIBRE_MAP_H

#include <QMapLibre/Export>
#include <QMapLibre/Settings>
#include <QMapLibre/Types>

Expand All @@ -24,9 +25,7 @@ namespace QMapLibre {

class MapPrivate;

// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style

class Q_MAPLIBRE_EXPORT Map : public QObject {
class Q_MAPLIBRE_CORE_EXPORT Map : public QObject {
Q_OBJECT
Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
Expand Down
2 changes: 1 addition & 1 deletion src/core/qmaplibre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// SPDX-License-Identifier: BSD-2-Clause

#include "export.hpp"
#include "export_core.hpp"
#include "map.hpp"
#include "settings.hpp"
#include "types.hpp"
Expand Down
8 changes: 3 additions & 5 deletions src/core/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
#ifndef QMAPLIBRE_SETTINGS_H
#define QMAPLIBRE_SETTINGS_H

#include <QMapLibre/Export>

#include <QImage>
#include <QString>

#include <functional>

#include "export.hpp"

// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style

// TODO: this will be wrapped at some point
namespace mbgl {
class TileServerOptions;
}

namespace QMapLibre {

class Q_MAPLIBRE_EXPORT Settings {
class Q_MAPLIBRE_CORE_EXPORT Settings {
public:
Settings();

Expand Down
20 changes: 10 additions & 10 deletions src/core/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#ifndef QMAPLIBRE_TYPES_H
#define QMAPLIBRE_TYPES_H

#include <QMapLibre/Export>

#include <QColor>
#include <QPair>
#include <QString>
#include <QVariant>
#include <QVector>

#include "export.hpp"

namespace QMapLibre {

typedef QPair<double, double> Coordinate;
Expand All @@ -25,7 +25,7 @@ typedef QVector<Coordinates> CoordinatesCollection;

typedef QVector<CoordinatesCollection> CoordinatesCollections;

struct Q_MAPLIBRE_EXPORT Feature {
struct Q_MAPLIBRE_CORE_EXPORT Feature {
enum Type {
PointType = 1,
LineStringType,
Expand All @@ -48,7 +48,7 @@ struct Q_MAPLIBRE_EXPORT Feature {
QVariant id;
};

struct Q_MAPLIBRE_EXPORT ShapeAnnotationGeometry {
struct Q_MAPLIBRE_CORE_EXPORT ShapeAnnotationGeometry {
enum Type {
LineStringType = 1,
PolygonType,
Expand All @@ -66,12 +66,12 @@ struct Q_MAPLIBRE_EXPORT ShapeAnnotationGeometry {
CoordinatesCollections geometry;
};

struct Q_MAPLIBRE_EXPORT SymbolAnnotation {
struct Q_MAPLIBRE_CORE_EXPORT SymbolAnnotation {
Coordinate geometry;
QString icon;
};

struct Q_MAPLIBRE_EXPORT LineAnnotation {
struct Q_MAPLIBRE_CORE_EXPORT LineAnnotation {
/*! Class constructor. */
LineAnnotation(const ShapeAnnotationGeometry &geometry_ = ShapeAnnotationGeometry(),
float opacity_ = 1.0f,
Expand All @@ -88,7 +88,7 @@ struct Q_MAPLIBRE_EXPORT LineAnnotation {
QColor color;
};

struct Q_MAPLIBRE_EXPORT FillAnnotation {
struct Q_MAPLIBRE_CORE_EXPORT FillAnnotation {
/*! Class constructor. */
FillAnnotation(const ShapeAnnotationGeometry &geometry_ = ShapeAnnotationGeometry(),
float opacity_ = 1.0f,
Expand All @@ -109,7 +109,7 @@ typedef QVariant Annotation;
typedef quint32 AnnotationID;
typedef QVector<AnnotationID> AnnotationIDs;

struct Q_MAPLIBRE_EXPORT CameraOptions {
struct Q_MAPLIBRE_CORE_EXPORT CameraOptions {
QVariant center; // Coordinate
QVariant anchor; // QPointF
QVariant zoom; // double
Expand All @@ -118,7 +118,7 @@ struct Q_MAPLIBRE_EXPORT CameraOptions {
};

// This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters.
struct Q_MAPLIBRE_EXPORT CustomLayerRenderParameters {
struct Q_MAPLIBRE_CORE_EXPORT CustomLayerRenderParameters {
double width;
double height;
double latitude;
Expand All @@ -129,7 +129,7 @@ struct Q_MAPLIBRE_EXPORT CustomLayerRenderParameters {
double fieldOfView;
};

class Q_MAPLIBRE_EXPORT CustomLayerHostInterface {
class Q_MAPLIBRE_CORE_EXPORT CustomLayerHostInterface {
public:
virtual ~CustomLayerHostInterface() = default;
virtual void initialize() = 0;
Expand Down
16 changes: 7 additions & 9 deletions src/core/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#ifndef QMAPLIBRE_UTILS_H
#define QMAPLIBRE_UTILS_H

#include "export.hpp"
#include "types.hpp"

// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style
#include <QMapLibre/Export>
#include <QMapLibre/Types>

namespace QMapLibre {

Expand All @@ -18,12 +16,12 @@ enum NetworkMode {
Offline,
};

Q_MAPLIBRE_EXPORT NetworkMode networkMode();
Q_MAPLIBRE_EXPORT void setNetworkMode(NetworkMode);
Q_MAPLIBRE_CORE_EXPORT NetworkMode networkMode();
Q_MAPLIBRE_CORE_EXPORT void setNetworkMode(NetworkMode);

Q_MAPLIBRE_EXPORT double metersPerPixelAtLatitude(double latitude, double zoom);
Q_MAPLIBRE_EXPORT ProjectedMeters projectedMetersForCoordinate(const Coordinate &);
Q_MAPLIBRE_EXPORT Coordinate coordinateForProjectedMeters(const ProjectedMeters &);
Q_MAPLIBRE_CORE_EXPORT double metersPerPixelAtLatitude(double latitude, double zoom);
Q_MAPLIBRE_CORE_EXPORT ProjectedMeters projectedMetersForCoordinate(const Coordinate &);
Q_MAPLIBRE_CORE_EXPORT Coordinate coordinateForProjectedMeters(const ProjectedMeters &);

} // namespace QMapLibre

Expand Down
2 changes: 1 addition & 1 deletion src/location/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif()
target_compile_definitions(
Location
PRIVATE
QT_BUILD_MAPLIBRE_LIB
QT_BUILD_MAPLIBRE_LOCATION_LIB
)

# Common include directories
Expand Down
20 changes: 20 additions & 0 deletions src/location/export_location.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2023 MapLibre contributors

// SPDX-License-Identifier: BSD-2-Clause

#ifndef QMAPLIBRE_LOCATION_EXPORT_H
#define QMAPLIBRE_LOCATION_EXPORT_H

#include <QtCore/QtGlobal>

#if !defined(QT_MAPLIBRE_STATIC)
#if defined(QT_BUILD_MAPLIBRE_LOCATION_LIB)
#define Q_MAPLIBRE_LOCATION_EXPORT Q_DECL_EXPORT
#else
#define Q_MAPLIBRE_LOCATION_EXPORT Q_DECL_IMPORT
#endif
#else
#define Q_MAPLIBRE_LOCATION_EXPORT
#endif

#endif // QMAPLIBRE_LOCATION_EXPORT_H
4 changes: 2 additions & 2 deletions src/location/qt_mapping_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include "../core/export.hpp"
#include "export_location.hpp"

#include <QMapLibre/Settings>

Expand All @@ -15,7 +15,7 @@

namespace QMapLibre {

class Q_MAPLIBRE_EXPORT QtMappingEngine : public QGeoMappingManagerEngine {
class Q_MAPLIBRE_LOCATION_EXPORT QtMappingEngine : public QGeoMappingManagerEngine {
Q_OBJECT

public:
Expand Down
15 changes: 12 additions & 3 deletions src/widgets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# Public headers
string(TOLOWER ${MLN_QT_NAME}Widgets MLN_QT_WIDGETS_LOWERCASE)
set(Widgets_Headers
export_widgets.hpp
gl_widget.hpp
)
# Header generation
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}Widgets/${MLN_QT_NAME}Widgets" "#include \"${MLN_QT_WIDGETS_LOWERCASE}.hpp\"")
list(APPEND Widgets_Headers_Generated "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}Widgets/${MLN_QT_NAME}Widgets")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}Widgets/GLWidget" "#include \"gl_widget.hpp\"")
list(APPEND Widgets_Headers_Generated "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}Widgets/GLWidget")
foreach(Header ${Widgets_Headers})
string(SUBSTRING ${Header} 0 1 HeaderFirstLetter)
string(TOUPPER ${HeaderFirstLetter} HeaderFirstLetter)
string(REGEX REPLACE "^.(.*)" "${HeaderFirstLetter}\\1" HeaderOut "${Header}")
string(REGEX REPLACE "\.hpp" "" HeaderOut "${HeaderOut}")
string(REPLACE "Export_widgets" "Export" HeaderOut "${HeaderOut}")
string(REPLACE "Gl_widget" "GLWidget" HeaderOut "${HeaderOut}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}Widgets/${HeaderOut}" "#include \"${Header}\"")
list(APPEND Widgets_Headers_Generated "${CMAKE_CURRENT_BINARY_DIR}/include/${MLN_QT_NAME}Widgets/${HeaderOut}")
endforeach()
set(Widgets_Headers ${MLN_QT_WIDGETS_LOWERCASE}.hpp ${Widgets_Headers} ${Widgets_Headers_Generated})

# Make a Qt library
Expand Down Expand Up @@ -46,7 +55,7 @@ endif()
target_compile_definitions(
Widgets
PRIVATE
QT_BUILD_MAPLIBRE_LIB
QT_BUILD_MAPLIBRE_WIDGETS_LIB
)

# Common include directories
Expand Down
20 changes: 20 additions & 0 deletions src/widgets/export_widgets.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2023 MapLibre contributors

// SPDX-License-Identifier: BSD-2-Clause

#ifndef QMAPLIBRE_WIDGETS_EXPORT_H
#define QMAPLIBRE_WIDGETS_EXPORT_H

#include <QtCore/QtGlobal>

#if !defined(QT_MAPLIBRE_STATIC)
#if defined(QT_BUILD_MAPLIBRE_WIDGETS_LIB)
#define Q_MAPLIBRE_WIDGETS_EXPORT Q_DECL_EXPORT
#else
#define Q_MAPLIBRE_WIDGETS_EXPORT Q_DECL_IMPORT
#endif
#else
#define Q_MAPLIBRE_WIDGETS_EXPORT
#endif

#endif // QMAPLIBRE_WIDGETS_EXPORT_H
4 changes: 3 additions & 1 deletion src/widgets/gl_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef QMAPLIBRE_GL_WIDGET_H
#define QMAPLIBRE_GL_WIDGET_H

#include <QMapLibreWidgets/Export>

#include <QMapLibre/Map>
#include <QMapLibre/Settings>

Expand All @@ -24,7 +26,7 @@ namespace QMapLibre {

class GLWidgetPrivate;

class Q_MAPLIBRE_EXPORT GLWidget : public QOpenGLWidget {
class Q_MAPLIBRE_WIDGETS_EXPORT GLWidget : public QOpenGLWidget {
Q_OBJECT

public:
Expand Down
1 change: 1 addition & 0 deletions src/widgets/qmaplibrewidgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

// SPDX-License-Identifier: BSD-2-Clause

#include "export_widgets.hpp"
#include "gl_widget.hpp"

0 comments on commit b8672ab

Please sign in to comment.