Only export symbols from the libraries that should be exported

Summary:
Using generate_export_header instead manually written export headers
should improve coverage across platforms.

Size of stripped libmarblewidget-qt5 reduced on Linux
e.g. from 11077592 to 7889848

Reviewers: rahn, #marble, nienhueser

Reviewed By: #marble, nienhueser

Differential Revision: https://phabricator.kde.org/D2309

# Conflicts:
#	src/lib/marble/AbstractFloatItem.h
#	src/lib/marble/marble_export.h
parent 8b99f625
...@@ -27,6 +27,13 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STRE ...@@ -27,6 +27,13 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STRE
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif() endif()
# Default to hidden visibility for symbols
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if (POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
#################################################### ####################################################
# Where to look first for cmake modules, # Where to look first for cmake modules,
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
using namespace Marble; using namespace Marble;
#ifdef Q_OS_ANDROID
// Declare symbol of main method as exported as needed by Qt-on-Android,
// where the Dalvik-native QtActivity class needs to find and invoke it
// on loading the "app" module
extern "C" Q_DECL_EXPORT
#endif
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
using namespace Marble; using namespace Marble;
#ifdef Q_OS_ANDROID
// Declare symbol of main method as exported as needed by Qt-on-Android,
// where the Dalvik-native QtActivity class needs to find and invoke it
// on loading the "app" module
extern "C" Q_DECL_EXPORT
#endif
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
......
...@@ -39,9 +39,6 @@ if(WIN32) ...@@ -39,9 +39,6 @@ if(WIN32)
endif(WIN32) endif(WIN32)
SET_TARGET_PROPERTIES(astro PROPERTIES
DEFINE_SYMBOL astro_EXPORTS # needed for astrolib_export.h
)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Android) if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
SET_TARGET_PROPERTIES(astro PROPERTIES SET_TARGET_PROPERTIES(astro PROPERTIES
VERSION ${GENERIC_LIB_VERSION} VERSION ${GENERIC_LIB_VERSION}
......
...@@ -361,6 +361,9 @@ qt_wrap_ui(marblewidget_SRCS ${marblewidget_UI}) ...@@ -361,6 +361,9 @@ qt_wrap_ui(marblewidget_SRCS ${marblewidget_UI})
ADD_LIBRARY(${MARBLEWIDGET} SHARED ${marblewidget_SRCS} ${SOURCES_UI_HDRS}) ADD_LIBRARY(${MARBLEWIDGET} SHARED ${marblewidget_SRCS} ${SOURCES_UI_HDRS})
generate_export_header(${MARBLEWIDGET} BASE_NAME marble)
# TODO: use PUBLIC/PRIVATE everywhere instead of LINK_PUBLIC/LINK_PRIVATE # TODO: use PUBLIC/PRIVATE everywhere instead of LINK_PUBLIC/LINK_PRIVATE
# once SailfishOS has cmake >= 2.8.12 # once SailfishOS has cmake >= 2.8.12
...@@ -427,11 +430,6 @@ endif() ...@@ -427,11 +430,6 @@ endif()
set_target_properties(${MARBLEWIDGET} PROPERTIES set_target_properties(${MARBLEWIDGET} PROPERTIES
COMPILE_FLAGS "-DKML_LAZY_IMP") COMPILE_FLAGS "-DKML_LAZY_IMP")
# needed for marble_export.h
set_target_properties(${MARBLEWIDGET} PROPERTIES
DEFINE_SYMBOL MAKE_MARBLE_LIB
)
# choose the correct target install library path # choose the correct target install library path
if(WIN32) if(WIN32)
install(TARGETS ${MARBLEWIDGET} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} ARCHIVE DESTINATION lib) install(TARGETS ${MARBLEWIDGET} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} ARCHIVE DESTINATION lib)
...@@ -457,6 +455,7 @@ else() ...@@ -457,6 +455,7 @@ else()
endif() endif()
install( FILES install( FILES
${CMAKE_CURRENT_BINARY_DIR}/marble_export.h
${graphicsview_HDRS} ${graphicsview_HDRS}
${marble_WebKit} ${marble_WebKit}
AutoNavigation.h AutoNavigation.h
...@@ -578,7 +577,6 @@ install( FILES ...@@ -578,7 +577,6 @@ install( FILES
LayerInterface.h LayerInterface.h
RenderState.h RenderState.h
PluginAboutDialog.h PluginAboutDialog.h
marble_export.h
Planet.h Planet.h
PlanetFactory.h PlanetFactory.h
EditPlacemarkDialog.h EditPlacemarkDialog.h
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#ifndef MARBLE_DBUSINTERFACE_H #ifndef MARBLE_DBUSINTERFACE_H
#define MARBLE_DBUSINTERFACE_H #define MARBLE_DBUSINTERFACE_H
#include "marble_export.h"
namespace Marble namespace Marble
{ {
class MarbleWidget; class MarbleWidget;
...@@ -23,7 +25,7 @@ namespace Marble ...@@ -23,7 +25,7 @@ namespace Marble
namespace Marble { namespace Marble {
class MarbleDBusInterface : public QDBusAbstractAdaptor class MARBLE_EXPORT MarbleDBusInterface : public QDBusAbstractAdaptor
{ {
Q_OBJECT Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.marble") Q_CLASSINFO("D-Bus Interface", "org.kde.marble")
......
...@@ -34,7 +34,10 @@ public: ...@@ -34,7 +34,10 @@ public:
*/ */
Planet(); Planet();
MARBLE_DEPRECATED( explicit Planet( const QString& id ) ); // please use PlanetFactory::construct(id) instead /**
* @deprecated Please use PlanetFactory::construct(id) instead.
*/
MARBLE_DEPRECATED explicit Planet(const QString& id);
///Copy Constructor ///Copy Constructor
Planet( const Planet& other ); Planet( const Planet& other );
...@@ -97,8 +100,14 @@ public: ...@@ -97,8 +100,14 @@ public:
Planet& operator=( const Planet& rhs ); Planet& operator=( const Planet& rhs );
MARBLE_DEPRECATED( static QString name( const QString& id ) ); // please use PlanetFactory::localizedName(id) instead /**
MARBLE_DEPRECATED( static QStringList planetList() ); // please use PlanetFactory::planetList() instead * @deprecated Please use PlanetFactory::localizedName(id) instead.
*/
MARBLE_DEPRECATED static QString name(const QString& id);
/**
* @deprecated Please use PlanetFactory::planetList() instead.
*/
MARBLE_DEPRECATED static QStringList planetList();
bool hasAtmosphere() const; bool hasAtmosphere() const;
void setHasAtmosphere( bool enabled ); void setHasAtmosphere( bool enabled );
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "marble_export.h" #include "marble_export.h"
#include <cmath> #include <cmath>
#include <QtGlobal>
namespace Marble namespace Marble
{ {
......
...@@ -14,13 +14,15 @@ ...@@ -14,13 +14,15 @@
#include <GeoDataStyle.h> #include <GeoDataStyle.h>
#include <GeoDataFeature.h> #include <GeoDataFeature.h>
#include "marble_export.h"
class QFont; class QFont;
class QColor; class QColor;
namespace Marble { namespace Marble {
class OsmPlacemarkData; class OsmPlacemarkData;
class StyleParameters class MARBLE_EXPORT StyleParameters
{ {
public: public:
explicit StyleParameters(const GeoDataFeature* feature=nullptr, int tileLevel=0); explicit StyleParameters(const GeoDataFeature* feature=nullptr, int tileLevel=0);
...@@ -29,7 +31,7 @@ public: ...@@ -29,7 +31,7 @@ public:
int tileLevel; int tileLevel;
}; };
class StyleBuilder class MARBLE_EXPORT StyleBuilder
{ {
public: public:
StyleBuilder(); StyleBuilder();
......
...@@ -32,10 +32,8 @@ add_library( marbledeclarative SHARED ...@@ -32,10 +32,8 @@ add_library( marbledeclarative SHARED
Settings.cpp Settings.cpp
) )
# needed for marble_declarative_export.h generate_export_header(marbledeclarative BASE_NAME marble_declarative)
set_target_properties(marbledeclarative PROPERTIES target_include_directories(marbledeclarative PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
DEFINE_SYMBOL MAKE_MARBLE_DECLARATIVE_LIB
)
marble_add_project_resources(qmldir) marble_add_project_resources(qmldir)
......
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2007 Christian Ehrlicher <ch.ehrlicher@gmx.de>
//
#ifndef MARBLE_DECLARATIVE_EXPORT_H
#define MARBLE_DECLARATIVE_EXPORT_H
#include <QtGlobal>
#ifndef MARBLE_DECLARATIVE_EXPORT
# ifdef MAKE_MARBLE_DECLARATIVE_LIB
# define MARBLE_DECLARATIVE_EXPORT Q_DECL_EXPORT
# else
# define MARBLE_DECLARATIVE_EXPORT Q_DECL_IMPORT
# endif
#endif
#endif // MARBLE_DECLARATIVE_EXPORT_H
...@@ -107,7 +107,7 @@ class GEODATA_EXPORT GeoDataContainer : public GeoDataFeature ...@@ -107,7 +107,7 @@ class GEODATA_EXPORT GeoDataContainer : public GeoDataFeature
*/ */
void insert( int index, GeoDataFeature *feature ); void insert( int index, GeoDataFeature *feature );
GEODATA_DEPRECATED( void insert( GeoDataFeature *other, int index ) ); GEODATA_DEPRECATED void insert(GeoDataFeature *other, int index);
/** /**
* @brief add an element * @brief add an element
......
...@@ -12,24 +12,10 @@ ...@@ -12,24 +12,10 @@
#ifndef GEODATA_EXPORT_H #ifndef GEODATA_EXPORT_H
#define GEODATA_EXPORT_H #define GEODATA_EXPORT_H
#include <QtGlobal> #include "marble_export.h"
// please make sure to change MAKE_MARBLE_LIB to MAKE_GEODATA_LIB if geodata is an independent library // please make sure to create a real export-header if geodata becomes an independent library
#ifndef GEODATA_EXPORT #define GEODATA_EXPORT MARBLE_EXPORT
# ifdef MAKE_MARBLE_LIB #define GEODATA_DEPRECATED MARBLE_DEPRECATED
# define GEODATA_EXPORT Q_DECL_EXPORT
# else
# define GEODATA_EXPORT Q_DECL_IMPORT
# endif
#endif
#ifdef __GNUC__
#define GEODATA_DEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define GEODATA_DEPRECATED(func) __declspec(deprecated) func
#else
#pragma message("WARNING: You need to implement GEODATA_DEPRECATED for this compiler in geodata_export.h")
#define GEODATA_DEPRECATED(func) func
#endif
#endif // GEODATA_EXPORT_H #endif // GEODATA_EXPORT_H
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2007 Christian Ehrlicher <ch.ehrlicher@gmx.de>
//
#ifndef MARBLE_EXPORT_H
#define MARBLE_EXPORT_H
#include <QtGlobal>
#ifndef MARBLE_EXPORT
# ifdef MAKE_MARBLE_LIB
# define MARBLE_EXPORT Q_DECL_EXPORT
# else
# define MARBLE_EXPORT Q_DECL_IMPORT
# endif
#endif
#ifdef __GNUC__
#define MARBLE_DEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define MARBLE_DEPRECATED(func) __declspec(deprecated) func
#else
#pragma message("WARNING: You need to implement MARBLE_DEPRECATED for this compiler in marble_export.h")
#define MARBLE_DEPRECATED(func) func
#endif
#endif // MARBLE_EXPORT_H
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "marble_export.h" #include "marble_export.h"
#include <QtGlobal>
class QTextStream; class QTextStream;
namespace Marble namespace Marble
......
...@@ -16,5 +16,3 @@ set(GeoCute_SRCS ...@@ -16,5 +16,3 @@ set(GeoCute_SRCS
) )
add_library(GeoCute SHARED ${GeoCute_SRCS}) add_library(GeoCute SHARED ${GeoCute_SRCS})
set_target_properties(GeoCute PROPERTIES DEFINE_SYMBOL MAKE_GEOCUTE_LIB)
...@@ -7,7 +7,6 @@ include_directories( ...@@ -7,7 +7,6 @@ include_directories(
) )
set( ${TARGET}_SRC constellations2kml.cpp ) set( ${TARGET}_SRC constellations2kml.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -7,7 +7,6 @@ include_directories( ...@@ -7,7 +7,6 @@ include_directories(
) )
set( ${TARGET}_SRC dateline.cpp ) set( ${TARGET}_SRC dateline.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -7,6 +7,5 @@ include_directories( ...@@ -7,6 +7,5 @@ include_directories(
) )
set( ${TARGET}_SRC kml2cache.cpp ) set( ${TARGET}_SRC kml2cache.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -7,7 +7,6 @@ include_directories( ...@@ -7,7 +7,6 @@ include_directories(
) )
set( ${TARGET}_SRC kml2kml.cpp ) set( ${TARGET}_SRC kml2kml.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -20,7 +20,6 @@ NearestNeighborInterpolation.cpp ...@@ -20,7 +20,6 @@ NearestNeighborInterpolation.cpp
NasaWorldWindToOpenStreetMapConverter.cpp NasaWorldWindToOpenStreetMapConverter.cpp
main.cpp main.cpp
) )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -8,7 +8,6 @@ include_directories( ...@@ -8,7 +8,6 @@ include_directories(
set( ${TARGET}_SRC main.cpp ) set( ${TARGET}_SRC main.cpp )
QT_ADD_RESOURCES( RESOURCES canvas.qrc ) QT_ADD_RESOURCES( RESOURCES canvas.qrc )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ${RESOURCES} ) add_executable( ${TARGET} ${${TARGET}_SRC} ${RESOURCES} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -25,7 +25,6 @@ PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ...@@ -25,7 +25,6 @@ PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS
pbf/fileformat.proto pbf/fileformat.proto
pbf/osmformat.proto pbf/osmformat.proto
) )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ${PROTO_SRCS} ${PROTO_HDRS} ) add_executable( ${TARGET} ${${TARGET}_SRC} ${PROTO_SRCS} ${PROTO_HDRS} )
target_link_libraries( ${TARGET} ${PROTOBUF_LIBRARIES} ${ZLIB_LIBRARIES} ) target_link_libraries( ${TARGET} ${PROTOBUF_LIBRARIES} ${ZLIB_LIBRARIES} )
......
...@@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 2.8.12) ...@@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 2.8.12)
SET (TARGET osm-simplify) SET (TARGET osm-simplify)
PROJECT (${TARGET}) PROJECT (${TARGET})
if (POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED) find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED) find_package(Qt5Gui REQUIRED)
...@@ -29,7 +33,6 @@ BaseFilter.cpp ...@@ -29,7 +33,6 @@ BaseFilter.cpp
NodeReducer.cpp NodeReducer.cpp
) )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} Qt5::Core marblewidget-qt5) target_link_libraries( ${TARGET} Qt5::Core marblewidget-qt5)
...@@ -16,7 +16,6 @@ upload.cpp ...@@ -16,7 +16,6 @@ upload.cpp
region.cpp region.cpp
main.cpp main.cpp
) )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} Qt5::Sql marblewidget-qt5 ) target_link_libraries( ${TARGET} Qt5::Sql marblewidget-qt5 )
...@@ -7,7 +7,6 @@ include_directories( ...@@ -7,7 +7,6 @@ include_directories(
) )
set( ${TARGET}_SRC main.cpp ) set( ${TARGET}_SRC main.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -13,7 +13,6 @@ set( routing-instructions_SRC ...@@ -13,7 +13,6 @@ set( routing-instructions_SRC
main.cpp main.cpp
) )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( routing-instructions ${routing-instructions_SRC} ) add_executable( routing-instructions ${routing-instructions_SRC} )
target_link_libraries( routing-instructions Qt5::Core ) target_link_libraries( routing-instructions Qt5::Core )
...@@ -7,7 +7,6 @@ include_directories( ...@@ -7,7 +7,6 @@ include_directories(
) )
set( ${TARGET}_SRC shp2pn2.cpp ) set( ${TARGET}_SRC shp2pn2.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
...@@ -7,7 +7,7 @@ include_directories( ...@@ -7,7 +7,7 @@ include_directories(
) )
set( ${TARGET}_SRC main.cpp tccore.cpp ) set( ${TARGET}_SRC main.cpp tccore.cpp )
add_definitions( -DMAKE_MARBLE_LIB -DTILECREATOR ) add_definitions(-DTILECREATOR)
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
......
...@@ -7,7 +7,6 @@ include_directories( ...@@ -7,7 +7,6 @@ include_directories(
) )
set( ${TARGET}_SRC main.cpp tccore.cpp ) set( ${TARGET}_SRC main.cpp tccore.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} ) add_executable( ${TARGET} ${${TARGET}_SRC} )
target_link_libraries( ${TARGET} marblewidget-qt5 ) target_link_libraries( ${TARGET} marblewidget-qt5 )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment