Skip to content

Commit

Permalink
fix windows build by cleaning up (dynamic) linkage and some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed May 24, 2011
1 parent 49a1ec6 commit 0b2317e
Show file tree
Hide file tree
Showing 24 changed files with 304 additions and 400 deletions.
30 changes: 10 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,27 +348,17 @@ IF(COMMAND cmake_policy)
ENDIF(COMMAND cmake_policy)

IF (WIN32)
# expect that classes are being imported
# Note: MSVC doesn't like when the macros are quotes
# and MSYS doesn't like them unqouted (bacause of braces)
IF (MSVC)
ADD_DEFINITIONS("-DCORE_EXPORT=__declspec(dllimport)")
ADD_DEFINITIONS("-DGUI_EXPORT=__declspec(dllimport)")
ADD_DEFINITIONS("-DPYTHON_EXPORT=__declspec(dllimport)")
ADD_DEFINITIONS("-DANALYSIS_EXPORT=__declspec(dllimport)")
ELSE (MSVC)
ADD_DEFINITIONS("\"-DCORE_EXPORT=__declspec(dllimport)\"")
ADD_DEFINITIONS("\"-DGUI_EXPORT=__declspec(dllimport)\"")
ADD_DEFINITIONS("\"-DPYTHON_EXPORT=__declspec(dllimport)\"")
ADD_DEFINITIONS("\"-DANALYSIS_EXPORT=__declspec(dllimport)\"")
ENDIF (MSVC)
SET(DLLIMPORT "__declspec(dllimport)")
SET(DLLEXPORT "__declspec(dllexport)")
ELSE (WIN32)
# other compilers don't use that MSVC construct
ADD_DEFINITIONS(-DCORE_EXPORT=)
ADD_DEFINITIONS(-DGUI_EXPORT=)
ADD_DEFINITIONS(-DPYTHON_EXPORT=)
ADD_DEFINITIONS(-DANALYSIS_EXPORT=)
ENDIF (WIN32)
SET(DLLIMPORT "")
SET(DLLEXPORT "")
ENDIF(WIN32)

ADD_DEFINITIONS("-DCORE_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DGUI_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DPYTHON_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLIMPORT}")

#############################################################
# user-changeable settings which can be used to customize
Expand Down
Empty file modified src/browser/qgsbrowsermodel.cpp
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions src/core/qgscredentials.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ QgsCredentials *QgsCredentials::smInstance = 0;
void QgsCredentials::setInstance( QgsCredentials *theInstance )
{
if ( smInstance )
{
QgsDebugMsg( "already registered an instance of QgsCredentials" );
}

smInstance = theInstance;
}
Expand Down
26 changes: 12 additions & 14 deletions src/core/qgsdataitem.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
***************************************************************************/
/* $Id$ */

#include <typeinfo>

#include <QApplication>
#include <QDateTime>
#include <QDir>
Expand Down Expand Up @@ -258,12 +256,12 @@ void QgsDataItem::refresh()

bool QgsDataItem::equal( const QgsDataItem *other )
{
if ( typeid ( this ) == typeid ( other ) &&
mPath == other->path() )
{
return true;
}
return false;
if ( metaObject()->className() == other->metaObject()->className() &&
mPath == other->path() )
{
return true;
}
return false;
}

// ---------------------------------------------------------------------
Expand Down Expand Up @@ -349,7 +347,7 @@ QgsDirectoryItem::QgsDirectoryItem( QgsDataItem* parent, QString name, QString p
QgsDebugMsg( library->fileName() + " has NoDataCapabilities" );
continue;
}
QgsDebugMsg( QString ( "%1 dataCapabilities : %2").arg(library->fileName()).arg(dataCapabilities() ) );
QgsDebugMsg( QString( "%1 dataCapabilities : %2" ).arg( library->fileName() ).arg( dataCapabilities() ) );
mLibraries.append( library );
}
else
Expand Down Expand Up @@ -380,11 +378,11 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
children.append( item );
}

QStringList fileEntries = dir.entryList( QDir::Dirs|QDir::NoDotAndDotDot|QDir::Files, QDir::Name );
QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
foreach( QString name, fileEntries )
{
QString path = dir.absoluteFilePath( name );
QFileInfo fileInfo ( path );
QFileInfo fileInfo( path );
foreach( QLibrary *library, mLibraries )
{
// we could/should create separate list of providers for each purpose
Expand All @@ -398,10 +396,10 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )

int capabilities = dataCapabilities();

if ( !( (fileInfo.isFile() && (capabilities & QgsDataProvider::File)) ||
(fileInfo.isDir() && (capabilities & QgsDataProvider::Dir))) )
if ( !(( fileInfo.isFile() && ( capabilities & QgsDataProvider::File ) ) ||
( fileInfo.isDir() && ( capabilities & QgsDataProvider::Dir ) ) ) )
{
continue;
continue;
}

dataItem_t * dataItem = ( dataItem_t * ) cast_to_fptr( library->resolve( "dataItem" ) );
Expand Down
Empty file modified src/core/qgsdataitem.h
100755 → 100644
Empty file.
11 changes: 7 additions & 4 deletions src/core/qgspallabeling.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,10 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
xPos, yPos, dataDefinedPosition, angle, dataDefinedRotation ) )
return;
}
catch ( std::exception* e )
catch ( std::exception &e )
{
QgsDebugMsg( QString( "Ignoring feature %1 due PAL exception: " ).arg( f.id() ) + QString::fromLatin1( e->what() ) );
Q_UNUSED( e );
QgsDebugMsg( QString( "Ignoring feature %1 due PAL exception: " ).arg( f.id() ) + QString::fromLatin1( e.what() ) );
return;
}

Expand Down Expand Up @@ -869,9 +870,10 @@ void QgsPalLabeling::registerDiagramFeature( QgsVectorLayer* layer, QgsFeature&
return;
}
}
catch ( std::exception* e )
catch ( std::exception &e )
{
QgsDebugMsg( QString( "Ignoring feature %1 due PAL exception: " ).arg( feat.id() ) + QString::fromLatin1( e->what() ) );
Q_UNUSED( e );
QgsDebugMsg( QString( "Ignoring feature %1 due PAL exception: " ).arg( feat.id() ) + QString::fromLatin1( e.what() ) );
return;
}

Expand Down Expand Up @@ -961,6 +963,7 @@ void QgsPalLabeling::drawLabeling( QgsRenderContext& context )
}
catch ( std::exception& e )
{
Q_UNUSED( e );
QgsDebugMsg( "PAL EXCEPTION :-( " + QString::fromLatin1( e.what() ) );
//mActiveLayers.clear(); // clean up
return;
Expand Down
1 change: 0 additions & 1 deletion src/core/qgssearchstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//! global function from parser.y that interfaces parser
extern QgsSearchTreeNode* parseSearchString( const QString& str, QString& parserErrorMsg );


QgsSearchString::QgsSearchString()
{
mTree = NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
}
catch ( const QgsCsException &cse )
{
Q_UNUSED( cse );
QgsDebugMsg( QString( "Failed to transform a point while drawing a feature of type '%1'. Ignoring this feature. %2" )
.arg( fet.typeName() ).arg( cse.what() ) );
}
Expand Down Expand Up @@ -920,6 +921,7 @@ void QgsVectorLayer::drawRendererV2Levels( QgsRenderContext& rendererContext, bo
}
catch ( const QgsCsException &cse )
{
Q_UNUSED( cse );
QgsDebugMsg( QString( "Failed to transform a point while drawing a feature of type '%1'. Ignoring this feature. %2" )
.arg( fet.typeName() ).arg( cse.what() ) );
}
Expand Down Expand Up @@ -1106,6 +1108,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse );
QgsDebugMsg( QString( "Failed to transform a point while drawing a feature of type '%1'. Rendering stopped. %2" )
.arg( fet.typeName() ).arg( cse.what() ) );
return false;
Expand Down Expand Up @@ -1446,7 +1449,9 @@ void QgsVectorLayer::updateExtents()
mLayerExtent.setMinimal();

if ( !mDataProvider )
{
QgsDebugMsg( "invoked with null mDataProvider" );
}

if ( mDeletedFeatureIds.isEmpty() && mChangedGeometries.isEmpty() )
{
Expand Down Expand Up @@ -1739,7 +1744,9 @@ bool QgsVectorLayer::nextFeature( QgsFeature &f )
}

if ( !found )
{
QgsDebugMsg( QString( "No attributes for the added feature %1 found" ).arg( f.id() ) );
}
}
else
{
Expand Down Expand Up @@ -1841,7 +1848,9 @@ bool QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeomet
}

if ( !found )
{
QgsDebugMsg( QString( "No attributes for the added feature %1 found" ).arg( f.id() ) );
}
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/grass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ SUBDIRS(modules-common ${GRASS_MODULES_DIR} scripts themes)

ADD_DEFINITIONS(-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\")
ADD_DEFINITIONS(-DHAVE_OPENPTY=${HAVE_OPENPTY})
ADD_DEFINITIONS("-DGRASS_EXPORT=${DLLIMPORT} -DGRASS_LIB_EXPORT=${DLLIMPORT}")

IF (WIN32)
ADD_DEFINITIONS(-DHAVE_GETPT "-DGRASS_EXPORT=__declspec(dllimport)")
ADD_DEFINITIONS(-DHAVE_GETPT)
ELSE (WIN32)
ADD_DEFINITIONS(-DHAVE_POSIX_OPENPT -DGRASS_EXPORT=)
ADD_DEFINITIONS(-DHAVE_POSIX_OPENPT)
ENDIF (WIN32)

########################################################
Expand Down Expand Up @@ -151,6 +152,7 @@ INCLUDE_DIRECTORIES(
TARGET_LINK_LIBRARIES(grassplugin
qgisgrass
qgis_gui
grassprovider
${OPENPTY_LIBRARY}
)

Expand Down
1 change: 1 addition & 0 deletions src/plugins/grass/qgsgrassplugin.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void QgsGrassPlugin::mapsetChanged()
}
catch ( QgsGrass::Exception &e )
{
Q_UNUSED( e );
QgsDebugMsg( "Cannot read GRASS CRS : " + QString( e.what() ) );
mCrs = QgsCoordinateReferenceSystem();
}
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/grass/qgsgrassplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ class QToolBar;
* \brief OpenModeller plugin for QGIS
*
*/
class QgsGrassPlugin: public QObject, public QgisPlugin
class QgsGrassPlugin : public QObject, public QgisPlugin
{
Q_OBJECT public:
Q_OBJECT

public:
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
Expand All @@ -68,7 +70,7 @@ class QgsGrassPlugin: public QObject, public QgisPlugin
*/
virtual int type();
//! Destructor
virtual ~ QgsGrassPlugin();
virtual ~QgsGrassPlugin();

//! Get Region Pen
QPen & regionPen( void );
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/grass/qgsgrassselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ void QgsGrassSelect::setLayers()
return;

QStringList layers = QgsGrass::vectorLayers( egisdbase->text(),
elocation->currentText(), emapset->currentText(),
emap->currentText().toUtf8() );
elocation->currentText(), emapset->currentText(),
emap->currentText().toUtf8() );

int idx = 0;
int sel = -1;
Expand Down
84 changes: 33 additions & 51 deletions src/providers/grass/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
ADD_DEFINITIONS(-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\")

########################################################
# Files

SET(GRASS_PROVIDER_SRCS provider.cpp qgsgrassprovider.cpp )

SET(GRASS_RASTER_PROVIDER_SRCS qgsgrassrasterprovider.cpp)

SET(GRASS_LIB_SRCS qgsgrass.cpp)

SET(QGIS_D_RAST_SRCS qgis.d.rast.c)

SET(QGIS_G_INFO_SRCS qgis.g.info.c)

########################################################
# Build

INCLUDE_DIRECTORIES (
INCLUDE_DIRECTORIES(
../../core
../../core/raster
${GRASS_INCLUDE_DIR}
Expand All @@ -25,18 +12,15 @@ INCLUDE_DIRECTORIES (
${GEOS_INCLUDE_DIR}
)

QT4_WRAP_CPP(GRASS_MOC_SRCS qgsgrassprovider.h)
ADD_LIBRARY (qgisgrass SHARED ${GRASS_LIB_SRCS} ${GRASS_MOC_SRCS})
#
# GRASS library
#

SET_TARGET_PROPERTIES(qgisgrass PROPERTIES VERSION ${COMPLETE_VERSION} SOVERSION ${COMPLETE_VERSION})

IF (WIN32)
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=__declspec(dllexport)\"" )
ELSE (WIN32)
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES COMPILE_FLAGS "-DGRASS_EXPORT=" )
ENDIF (WIN32)

TARGET_LINK_LIBRARIES (qgisgrass
ADD_LIBRARY(qgisgrass SHARED qgsgrass.cpp)
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES
VERSION ${COMPLETE_VERSION} SOVERSION ${COMPLETE_VERSION}
COMPILE_FLAGS "\"-DGRASS_LIB_EXPORT=${DLLEXPORT}\" \"-DGRASS_EXPORT=${DLLIMPORT}\"" )
TARGET_LINK_LIBRARIES(qgisgrass
qgis_core
${GRASS_LIBRARY_gis}
${GRASS_LIBRARY_vect}
Expand All @@ -49,43 +33,41 @@ IF (APPLE)
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE )
ENDIF (APPLE)

ADD_LIBRARY (grassprovider MODULE ${GRASS_PROVIDER_SRCS} ${GRASS_MOC_SRCS})
#
# GRASS vector provider
#

IF (WIN32)
SET_TARGET_PROPERTIES(grassprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=__declspec(dllexport)\"" )
ELSE (WIN32)
SET_TARGET_PROPERTIES(grassprovider PROPERTIES COMPILE_FLAGS "-DGRASS_EXPORT=" )
ENDIF (WIN32)

TARGET_LINK_LIBRARIES (grassprovider
qgisgrass
)
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS qgsgrassprovider.h)
ADD_LIBRARY(grassprovider SHARED qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
SET_TARGET_PROPERTIES(grassprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=${DLLEXPORT}\" \"-DGRASS_LIB_EXPORT=${DLLIMPORT}\"" )
TARGET_LINK_LIBRARIES(grassprovider qgisgrass)

QT4_WRAP_CPP(GRASS_MOC_RASTERSRCS qgsgrassrasterprovider.h)
ADD_LIBRARY (grassrasterprovider MODULE ${GRASS_RASTER_PROVIDER_SRCS} ${GRASS_MOC_RASTERSRCS})
#
# grass raster provider
#

IF (WIN32)
SET_TARGET_PROPERTIES(grassrasterprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=__declspec(dllexport)\"" )
ELSE (WIN32)
SET_TARGET_PROPERTIES(grassrasterprovider PROPERTIES COMPILE_FLAGS "-DGRASS_EXPORT=" )
ENDIF (WIN32)

TARGET_LINK_LIBRARIES (grassrasterprovider
qgisgrass
qgis_core
)
QT4_WRAP_CPP(GRASS_RASTERPROVIDER_MOC_SRCS qgsgrassrasterprovider.h)
ADD_LIBRARY(grassrasterprovider MODULE qgsgrassrasterprovider.cpp ${GRASS_RASTERPROVIDER_MOC_SRCS})
SET_TARGET_PROPERTIES(grassrasterprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=${DLLEXPORT}\" \"-DGRASS_LIB_EXPORT=${DLLIMPORT}\"" )
TARGET_LINK_LIBRARIES(grassrasterprovider qgisgrass qgis_core)

ADD_EXECUTABLE(qgis.d.rast ${QGIS_D_RAST_SRCS})
#
# grass raster display module
#

TARGET_LINK_LIBRARIES (qgis.d.rast
ADD_EXECUTABLE(qgis.d.rast qgis.d.rast.c)
TARGET_LINK_LIBRARIES(qgis.d.rast
${GRASS_LIBRARY_gis}
${GRASS_LIBRARY_datetime}
${GDAL_LIBRARY}
)

ADD_EXECUTABLE(qgis.g.info ${QGIS_G_INFO_SRCS})
#
# grass info module
#

TARGET_LINK_LIBRARIES (qgis.g.info
ADD_EXECUTABLE(qgis.g.info qgis.g.info.c)
TARGET_LINK_LIBRARIES(qgis.g.info
${GRASS_LIBRARY_gis}
${GRASS_LIBRARY_datetime}
${GRASS_LIBRARY_gproj}
Expand Down
Loading

0 comments on commit 0b2317e

Please sign in to comment.