Navigation Menu

Skip to content

Commit

Permalink
Applied Jürgens patch with improvements for MSVC build and initial at…
Browse files Browse the repository at this point in the history
…tempts at GRASS under MSVC

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7322 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Nov 5, 2007
1 parent 37233b6 commit 4c3fea2
Show file tree
Hide file tree
Showing 54 changed files with 274 additions and 238 deletions.
21 changes: 17 additions & 4 deletions python/CMakeLists.txt
@@ -1,9 +1,16 @@

IF (WIN32)
SET(BINDINGS_CORE_LIB ${CMAKE_CURRENT_BINARY_DIR}/core/core.pyd)
SET(BINDINGS_GUI_LIB ${CMAKE_CURRENT_BINARY_DIR}/gui/gui.pyd)
SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/libqgis_core.dll)
SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/libqgis_gui.dll)
IF (NOT MSVC)
SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/libqgis_core.dll)
SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/libqgis_gui.dll)
ELSE (NOT MSVC)
SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/${CMAKE_CFG_INTDIR}/qgis_core.lib)
SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/${CMAKE_CFG_INTDIR}/qgis_gui.lib)
GET_FILENAME_COMPONENT(GDAL_LIB_PATH ${GDAL_LIBRARY} PATH)
GET_FILENAME_COMPONENT(GDAL_LIB_NAME ${GDAL_LIBRARY} NAME_WE)
SET(GDAL_LIB_PATHNAME ${GDAL_LIB_PATH}/${GDAL_LIB_NAME})
ENDIF (NOT MSVC)
ELSE (WIN32)
SET(BINDINGS_CORE_LIB ${CMAKE_CURRENT_BINARY_DIR}/core/core.so)
SET(BINDINGS_GUI_LIB ${CMAKE_CURRENT_BINARY_DIR}/gui/gui.so)
Expand Down Expand Up @@ -35,14 +42,20 @@ FILE(GLOB GUI_SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/gui/*.sip")
# create file configure.py from configure.py.in
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/configure.py.in
${CMAKE_CURRENT_BINARY_DIR}/configure.py)

IF (MSVC)
SET(EXPORT "__declspec(dllimport)")
ELSE (MSVC)
SET(EXPORT "")
ENDIF (MSVC)

# Step 2: during make
# run python configure.py
# it will run SIP utility to generate sources and will prepare makefiles
# should be run everytime core or gui library has been changed
ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_CORE_MAKEFILE} ${BINDINGS_GUI_MAKEFILE} PRE_BUILD
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${CMAKE_CURRENT_BINARY_DIR}/configure.py
ARGS ${CMAKE_CURRENT_BINARY_DIR}/configure.py ${CMAKE_CFG_INTDIR} ${EXPORT}
DEPENDS ${QGIS_CORE_LIB} ${QGIS_GUI_LIB}
${CMAKE_CURRENT_BINARY_DIR}/configure.py
${CORE_SIP_FILES} ${GUI_SIP_FILES})
Expand Down
21 changes: 17 additions & 4 deletions python/configure.py.in
Expand Up @@ -9,12 +9,23 @@ build_path = '@CMAKE_BINARY_DIR@'
python_path = src_path + '/python'
gdal_inc_dir = '@GDAL_INCLUDE_DIR@'
geos_inc_dir = '@GEOS_INCLUDE_DIR@'
gdal_library = '@GDAL_LIB_PATHNAME@'

qt_libs = ["QtCore","QtGui","QtNetwork","QtSvg","QtXml"]
if sys.platform == 'darwin':
qt_libs.append("Qt3Support")
qt_libs.append("QtSql")

if len(sys.argv)>1:
intdir = "/" + sys.argv[1]
else:
intdir = ""

if len(sys.argv)>2:
export = sys.argv[2]
else:
export = ""

# create paths for temporary files if don't exist
if not os.path.isdir("./core"):
os.mkdir("./core")
Expand Down Expand Up @@ -99,7 +110,9 @@ makefile_gui = sipconfig.ModuleMakefile(
# common settings for both core and gui libs
for mk in [ makefile_core, makefile_gui ]:
mk.extra_libs = ["qgis_core"]
mk.extra_lib_dirs = [build_path+"/src/core"]
if gdal_library!="":
mk.extra_libs.append(gdal_library)
mk.extra_lib_dirs = [build_path+"/src/core"+intdir]
mk.extra_include_dirs = [src_path+"/src/core",
src_path+"/src/core/raster",
src_path+"/src/core/renderer",
Expand All @@ -108,16 +121,16 @@ for mk in [ makefile_core, makefile_gui ]:
build_path, # qgsconfig.h, qgssvnversion.h
gdal_inc_dir,
geos_inc_dir]
mk.extra_cxxflags = ["-DCORE_EXPORT="]
mk.extra_cxxflags = ["-DCORE_EXPORT="+export]

# more settings for gui lib
makefile_gui.extra_libs.append("qgis_gui")
makefile_gui.extra_lib_dirs.append(build_path+"/src/gui")
makefile_gui.extra_lib_dirs.append(build_path+"/src/gui"+intdir)
makefile_gui.extra_include_dirs.append(src_path+"/src/gui")
makefile_gui.extra_include_dirs.append(build_path+"/src/gui")
makefile_gui.extra_include_dirs.append(build_path+"/src/ui")
makefile_gui.extra_include_dirs.append(src_path+"/src/plugins") # because of qgisplugin.h TODO: sort out
makefile_gui.extra_cxxflags.append("-DGUI_EXPORT=")
makefile_gui.extra_cxxflags.append("-DGUI_EXPORT="+export)

# Generate the Makefile itself.
makefile_core.generate()
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposition.cpp
Expand Up @@ -600,6 +600,7 @@ void QgsComposition::paperSizeChanged ( void )
}
catch (std::bad_alloc& ba)
{
UNUSED(ba);
// A better solution here would be to set the canvas back to the
// original size and carry on, but for the moment this will
// prevent a crash due to an uncaught exception.
Expand Down
1 change: 1 addition & 0 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -42,6 +42,7 @@
#include <iostream>

#include <QFont>
#include <QDomDocument>
#include <QHeaderView>
#include <QMenu>
#include <QMessageBox>
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -3020,6 +3020,7 @@ void QgisApp::openProject(const QString & fileName)
}
catch ( QgsIOException & io_exception )
{
UNUSED(io_exception);
QMessageBox::critical( this,
tr("QGIS: Unable to load project"),
tr("Unable to load project ") + fileName );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsbookmarks.h
Expand Up @@ -23,7 +23,7 @@
class QString;
class QWidget;
class Q3ListViewItem;
class sqlite3;
struct sqlite3;
class QgsBookmarks : public QDialog, private Ui::QgsBookmarksBase
{
Q_OBJECT
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -112,6 +112,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
}
catch(QgsCsException &cse)
{
UNUSED(cse);
QMessageBox::information(0, QObject::tr("Coordinate transform error"), \
QObject::tr("Cannot transform the point to the layers coordinate system"));
return;
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsmaptoolcapture.cpp
Expand Up @@ -113,6 +113,7 @@ int QgsMapToolCapture::addVertex(const QPoint& p)
}
catch(QgsCsException &cse)
{
UNUSED(cse); // unused
return 2; //cannot reproject point to layer coordinate system
}

Expand Down
1 change: 1 addition & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -500,6 +500,7 @@ QString QgsVectorLayerProperties::getMetadata()
}
catch(QgsCsException &cse)
{
UNUSED(cse);
QgsDebugMsg( cse.what() );

myMetadataQString += "<tr><td bgcolor=\"white\">";
Expand Down
19 changes: 19 additions & 0 deletions src/core/qgis.h
Expand Up @@ -130,5 +130,24 @@ class CORE_EXPORT QGis
* or user (~/.qgis.qgis.db) defined projection. */
const int USER_PROJECTION_START_ID=100000;

#ifdef WIN32
// fake use to make unused variable warnings go away in Visual C++
#define UNUSED(symbol) symbol
#else
# define UNUSED(symbol)
#endif

// FIXME: also in qgisinterface.h
#ifndef QGISEXTERN
#ifdef WIN32
# define QGISEXTERN extern "C" __declspec( dllexport )
# ifdef _MSC_VER
// do not warn about C bindings returing QString
# pragma warning(disable:4190)
# endif
#else
# define QGISEXTERN extern "C"
#endif
#endif

#endif
4 changes: 4 additions & 0 deletions src/core/qgsdistancearea.cpp
Expand Up @@ -282,6 +282,7 @@ double QgsDistanceArea::measureLine(const QList<QgsPoint>& points)
}
catch (QgsCsException &cse)
{
UNUSED(cse);
QgsLogger::warning(QObject::tr("Caught a coordinate system exception while trying to transform a point. Unable to calculate line length."));
return 0.0;
}
Expand All @@ -306,6 +307,7 @@ double QgsDistanceArea::measureLine(const QgsPoint& p1, const QgsPoint& p2)
}
catch (QgsCsException &cse)
{
UNUSED(cse);
QgsLogger::warning(QObject::tr("Caught a coordinate system exception while trying to transform a point. Unable to calculate line length."));
return 0.0;
}
Expand Down Expand Up @@ -365,6 +367,7 @@ unsigned char* QgsDistanceArea::measurePolygon(unsigned char* feature, double* a
}
catch (QgsCsException &cse)
{
UNUSED(cse);
QgsLogger::warning(QObject::tr("Caught a coordinate system exception while trying to transform a point. Unable to calculate polygon area."));
}

Expand Down Expand Up @@ -393,6 +396,7 @@ double QgsDistanceArea::measurePolygon(const QList<QgsPoint>& points)
}
catch (QgsCsException &cse)
{
UNUSED(cse);
QgsLogger::warning(QObject::tr("Caught a coordinate system exception while trying to transform a point. Unable to calculate polygon area."));
return 0.0;
}
Expand Down
7 changes: 4 additions & 3 deletions src/core/qgslabel.cpp
Expand Up @@ -352,9 +352,10 @@ void QgsLabel::renderLabel(QPainter* painter, QgsPoint point,
}
catch(QgsCsException &cse)
{
QgsDebugMsg("Caught transform error in QgsLabel::renderLabel(). "
"Skipping rendering this label");
return;
UNUSED(cse); // unused otherwise
QgsDebugMsg("Caught transform error in QgsLabel::renderLabel(). "
"Skipping rendering this label");
return;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/core/qgsmaprender.cpp
Expand Up @@ -454,6 +454,7 @@ bool QgsMapRender::splitLayersExtent(QgsMapLayer* layer, QgsRect& extent, QgsRec
}
catch (QgsCsException &cse)
{
UNUSED(cse);
QgsLogger::warning("Transform error caught in " + QString(__FILE__) + ", line " + QString::number(__LINE__));
extent = QgsRect(-DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX);
r2 = QgsRect(-DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX);
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -316,6 +316,7 @@ void QgsVectorLayer::drawLabels(QPainter * p, QgsRect & viewExtent, QgsMapToPixe
}
catch (QgsCsException &e)
{
UNUSED(e);
QgsLogger::critical("Error projecting label locations, caught in " + QString(__FILE__) + ", line " +QString(__LINE__));
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -59,8 +59,8 @@ email : tim at linfiniti.com
// workaround for MSVC compiler which already has defined macro max
// that interferes with calling std::numeric_limits<int>::max
#ifdef _MSC_VER
# ifdef max(x,y)
# undef max(x,y)
# ifdef max
# undef max
# endif
#endif

Expand Down
10 changes: 10 additions & 0 deletions src/core/spatialindex/rtree/BulkLoader.cc
Expand Up @@ -30,6 +30,14 @@

#include "BulkLoader.h"

#ifdef _MSC_VER
// tell MSVC not to complain about exception declarations
#pragma warning(disable:4290)
#define UNUSED(symbol) symbol
#else
#define UNUSED(symbol)
#endif

using namespace SpatialIndex::RTree;

BulkLoadSource::BulkLoadSource(
Expand Down Expand Up @@ -179,6 +187,7 @@ IData* BulkLoader::TmpFile::getNext()
}
catch (Tools::EndOfStreamException& e)
{
UNUSED(e);
m_pNext = 0;
}
catch (...)
Expand Down Expand Up @@ -220,6 +229,7 @@ void BulkLoader::TmpFile::rewind()
}
catch (Tools::EndOfStreamException& e)
{
UNUSED(e);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/core/spatialindex/rtree/BulkLoader.h
Expand Up @@ -22,6 +22,12 @@
#ifndef __spatialindex_rtree_bulk_loader_h
#define __spatialindex_rtree_bulk_loader_h

#ifdef _MSC_VER
// tell MSVC not to complain about exception declarations
#pragma warning(push)
#pragma warning(disable:4290)
#endif

namespace SpatialIndex
{
namespace RTree
Expand Down Expand Up @@ -108,5 +114,10 @@ namespace SpatialIndex
}
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif


#endif /* __spatialindex_rtree_bulk_loader_h */

2 changes: 1 addition & 1 deletion src/core/spatialindex/rtree/RTree.cc
Expand Up @@ -1065,7 +1065,7 @@ void SpatialIndex::RTree::RTree::loadHeader()
ptr += sizeof(unsigned long);
char c;
memcpy(&c, ptr, sizeof(char));
m_bTightMBRs = (bool) c;
m_bTightMBRs = c!=0;
ptr += sizeof(char);
memcpy(&(m_stats.m_nodes), ptr, sizeof(unsigned long));
ptr += sizeof(unsigned long);
Expand Down
8 changes: 8 additions & 0 deletions src/core/spatialindex/tools/ExternalSort.cc
Expand Up @@ -26,6 +26,12 @@

#include "ExternalSort.h"

#ifdef _MSC_VER
#define UNUSED(symbol) symbol
#else
#define UNUSED(symbol)
#endif

using namespace std;

Tools::ExternalSort::PQEntry::PQEntry(
Expand Down Expand Up @@ -202,6 +208,7 @@ void Tools::ExternalSort::mergeRuns()
}
catch (EndOfStreamException& e)
{
UNUSED(e);
// if there are no more records in the file, do nothing.
}

Expand All @@ -222,6 +229,7 @@ void Tools::ExternalSort::mergeRuns()
}
catch (EndOfStreamException& e)
{
UNUSED(e);
// if there are no more records in the file, do nothing.
delete pqe;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/spatialindex/tools/Tools.cc
Expand Up @@ -205,7 +205,7 @@ void Tools::PropertySet::loadFromByteArray(const byte* ptr)
byte bl;
memcpy(&bl, ptr, sizeof(byte));
ptr += sizeof(byte);
v.m_val.blVal = static_cast<bool>(bl);
v.m_val.blVal = bl!=0;
break;
default:
throw IllegalStateException(
Expand Down
13 changes: 13 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -124,4 +124,17 @@ class GUI_EXPORT QgisInterface : public QObject

};

// FIXME: also in core/qgis.h
#ifndef QGISEXTERN
#ifdef WIN32
# define QGISEXTERN extern "C" __declspec( dllexport )
# ifdef _MSC_VER
// do not warn about C bindings returing QString
# pragma warning(disable:4190)
# endif
#else
# define QGISEXTERN extern "C"
#endif
#endif

#endif //#ifndef QGISINTERFACE_H
2 changes: 1 addition & 1 deletion src/helpviewer/qgshelpviewer.h
Expand Up @@ -21,7 +21,7 @@
#define QGSHELPVIEWER_H
# include "ui_qgshelpviewerbase.h"
class QString;
class sqlite3;
struct sqlite3;
class QgsHelpViewer : public QDialog, private Ui::QgsHelpViewerBase
{
Q_OBJECT
Expand Down
6 changes: 0 additions & 6 deletions src/plugins/copyright_label/plugin.cpp
Expand Up @@ -46,12 +46,6 @@ email : tim@linfiniti.com
// xpm for creating the toolbar icon
#include "icon.xpm"

#ifdef WIN32
#define QGISEXTERN extern "C" __declspec( dllexport )
#else
#define QGISEXTERN extern "C"
#endif

static const char * const ident_ = "$Id$";

static const QString name_ = QObject::tr("CopyrightLabel");
Expand Down

0 comments on commit 4c3fea2

Please sign in to comment.