Skip to content

Commit

Permalink
Applied patch from David Willis for msvc/win32 build support
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7226 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Sep 27, 2007
1 parent b406f1d commit c7dba65
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ IF (WIN32)
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/plugins)
SET (QGIS_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
SET (QGIS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
IF(MSVC)
# Turn on defines for non standard maths stuff
ADD_DEFINITIONS(-D_USE_MATH_DEFINES)

# Some file access stuff not defined in native win32
# environment
ADD_DEFINITIONS(-DF_OK=0)
ADD_DEFINITIONS(-DX_OK=1)
ADD_DEFINITIONS(-DW_OK=2)
ADD_DEFINITIONS(-DR_OK=4)
ENDIF(MSVC)

ELSE (WIN32)

Expand Down
6 changes: 3 additions & 3 deletions cmake_templates/svnscript.cmake.in_cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ FIND_PROGRAM(SVNVERSION svnversion)

# Read the version if installed, else set to "unknown"
IF (SVNVERSION)
EXEC_PROGRAM(${SVNVERSION} ARGS @CMAKE_CURRENT_SOURCE_DIR@ OUTPUT_VARIABLE MYVERSION)
EXEC_PROGRAM(${SVNVERSION} ARGS "@CMAKE_CURRENT_SOURCE_DIR@" OUTPUT_VARIABLE MYVERSION)
ELSE (SVNVERSION)
SET(MYVERSION unknown)
ENDIF (SVNVERSION)

# Configure the qgssvnversion.h
CONFIGURE_FILE(@CMAKE_CURRENT_SOURCE_DIR@/cmake_templates/qgssvnversion.h.in_cmake
@CMAKE_CURRENT_BINARY_DIR@/qgssvnversion.h)
CONFIGURE_FILE("@CMAKE_CURRENT_SOURCE_DIR@/cmake_templates/qgssvnversion.h.in_cmake"
"@CMAKE_CURRENT_BINARY_DIR@/qgssvnversion.h")
4 changes: 4 additions & 0 deletions src/app/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include <QPainter>
#include <iostream>
#include <cmath>
// round isn't defined by default in msvc
#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

QgsComposerMap::QgsComposerMap ( QgsComposition *composition, int id, int x, int y, int width, int height )
: QWidget(), QGraphicsRectItem(0,0,width,height,0)
Expand Down
9 changes: 7 additions & 2 deletions src/app/legend/qgslegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ class QTreeWidgetItem;
class QgsLegend : public QTreeWidget
{
Q_OBJECT;

private:
// Moved here to match access of declaration later in file.
// Previous location raised a warning in msvc as the forward
// declaration was public while the definition was private
class QgsLegendPixmaps;


public:
/*! Constructor.
* @param qgis_app link to qgisapp
Expand Down Expand Up @@ -169,7 +175,6 @@ class QgsLegend : public QTreeWidget
/**Sets the toggle editing action. Usually called from QgisApp*/
void setToggleEditingAction(QAction* editingAction){mToggleEditingAction = editingAction;}

class QgsLegendPixmaps;
/**Returns structure with legend pixmaps*/
QgsLegendPixmaps& pixmaps() { return mPixmaps; }

Expand Down
10 changes: 10 additions & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
#include <fcntl.h> /* _O_BINARY */
#undef _fmode
int _fmode = _O_BINARY;
#ifndef _MSC_VER
// Only do this if we are not building on windows with msvc.
// Recommended method for doing this with msvc is with a call to _set_fmode
// which is the first thing we do in main().
#undef _fmode
int _fmode = _O_BINARY;
#endif//_MSC_VER
#else
#include <getopt.h>
#endif
Expand Down Expand Up @@ -216,6 +223,9 @@ void myMessageOutput( QtMsgType type, const char *msg )

int main(int argc, char *argv[])
{
#ifdef _MSC_VER
_set_fmode(_O_BINARY);
#endif

// Set up the custom qWarning/qDebug custom handler
qInstallMsgHandler( myMessageOutput );
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class CORE_EXPORT QgsApplication: public QApplication
*/
static QString reportStyleSheet();
private:
CORE_EXPORT static QString mPrefixPath;
CORE_EXPORT static QString mPluginPath;
CORE_EXPORT static QString mPkgDataPath;
CORE_EXPORT static QString mThemePath;
static QString mPrefixPath;
static QString mPluginPath;
static QString mPkgDataPath;
static QString mThemePath;
};

#endif
20 changes: 20 additions & 0 deletions src/core/spatialindex/geometry/LineSegment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ bool Tools::Geometry::LineSegment::touchesShape(const IShape& s) const

void Tools::Geometry::LineSegment::getCenter(Point& out) const
{
#ifdef _MSC_VER
// MSVC doesn't like non-const array initialisers
double* coords = new double[m_dimension];
#else
double coords[m_dimension];
#endif//_MSC_VER

for (unsigned long cDim = 0; cDim < m_dimension; cDim++)
{
Expand All @@ -180,6 +185,10 @@ void Tools::Geometry::LineSegment::getCenter(Point& out) const
}

out = Point(coords, m_dimension);

#ifdef _MSC_VER
delete[] coords;
#endif//_MSC_VER
}

unsigned long Tools::Geometry::LineSegment::getDimension() const
Expand All @@ -189,8 +198,14 @@ unsigned long Tools::Geometry::LineSegment::getDimension() const

void Tools::Geometry::LineSegment::getMBR(Region& out) const
{
#ifdef _MSC_VER
// MSVC doesn't like non-const array initialisers
double* low = new double[m_dimension];
double* high = new double[m_dimension];
#else
double low[m_dimension];
double high[m_dimension];
#endif//_MSC_VER

for (unsigned long cDim = 0; cDim < m_dimension; cDim++)
{
Expand All @@ -199,6 +214,11 @@ void Tools::Geometry::LineSegment::getMBR(Region& out) const
}

out = Region(low, high, m_dimension);

#ifdef _MSC_VER
delete[] low;
delete[] high;
#endif//_MSC_VER
}

double Tools::Geometry::LineSegment::getArea() const
Expand Down
6 changes: 6 additions & 0 deletions src/core/spatialindex/include/RTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ namespace SpatialIndex
unsigned long m_dataLength;
}; // Data

#ifdef _MSC_VER
// MSVC didn't like the difference in parameter names between declaration
// definition
extern ISpatialIndex* returnRTree(IStorageManager& sm, Tools::PropertySet& ps);
#else
extern ISpatialIndex* returnRTree(IStorageManager& in, Tools::PropertySet& in);
#endif//_MSC_VER
extern ISpatialIndex* createNewRTree(
IStorageManager& sm,
double fillFactor,
Expand Down
6 changes: 6 additions & 0 deletions src/core/spatialindex/include/SpatialIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ namespace SpatialIndex
extern IStorageManager* createNewDiskStorageManager(std::string& baseName, unsigned long pageSize);
extern IStorageManager* loadDiskStorageManager(std::string& baseName);

#ifdef _MSC_VER
// MSVC didn't like the difference in parameter names between declaration
// definition
extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& sm, Tools::PropertySet& ps);
#else
extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& in, Tools::PropertySet& in);
#endif//_MSC_VER
extern IBuffer* createNewRandomEvictionsBuffer(IStorageManager& in, unsigned int capacity, bool bWriteThrough);
}

Expand Down
22 changes: 22 additions & 0 deletions src/core/spatialindex/include/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#ifndef __tools_h
#define __tools_h

#ifdef _MSC_VER
#include <locale>
#include <limits>
#endif//_MSC_VER
#include <stdint.h>
#include <assert.h>
#include <iostream>
Expand Down Expand Up @@ -402,10 +406,19 @@ namespace Tools
private:
std::map<std::string, Variant> m_propertySet;

#ifdef _MSC_VER
// MSVC's friend function syntax differs slightly from everyone elses:
// don't seem to need to qualify function name.
friend std::ostream& operator<<(
std::ostream& os,
const Tools::PropertySet& p
);
#else
friend std::ostream& Tools::operator<<(
std::ostream& os,
const Tools::PropertySet& p
);
#endif//_MSC_VER
}; // PropertySet

std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p);
Expand Down Expand Up @@ -606,10 +619,19 @@ namespace Tools
unsigned long long* m_a;
unsigned long m_k;

#ifdef _MSC_VER
// MSVC's friend function syntax differs slightly from everyone elses
// don't seem to need to qualify function name.
friend std::ostream& operator<<(
std::ostream& os,
const Tools::UniversalHash& h
);
#else
friend std::ostream& Tools::operator<<(
std::ostream& os,
const Tools::UniversalHash& h
);
#endif//_MSC_VER
}; // UniversalHash

std::ostream& operator<<(std::ostream& os, const Tools::UniversalHash& h);
Expand Down
15 changes: 15 additions & 0 deletions src/core/spatialindex/rtree/BulkLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ void BulkLoader::TmpFile::rewind()
}

void BulkLoader::bulkLoadUsingSTR(
#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
SpatialIndex::RTree::RTree* pTree,
#else
RTree* pTree,
#endif//_MSC_VER
IDataStream& stream,
unsigned long bindex,
unsigned long bleaf,
Expand Down Expand Up @@ -277,7 +282,12 @@ void BulkLoader::bulkLoadUsingSTR(
}

void BulkLoader::createLevel(
#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
SpatialIndex::RTree::RTree* pTree,
#else
RTree* pTree,
#endif//_MSC_VER
Tools::IObjectStream& stream,
unsigned long dimension,
unsigned long k,
Expand Down Expand Up @@ -340,7 +350,12 @@ void BulkLoader::createLevel(
}
}

#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Node* BulkLoader::createNode(SpatialIndex::RTree::RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, unsigned long level)
#else
Node* BulkLoader::createNode(RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, unsigned long level)
#endif//_MSC_VER
{
Node* n;

Expand Down
5 changes: 5 additions & 0 deletions src/core/spatialindex/rtree/Index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ Index::~Index()
{
}

#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Index::Index(SpatialIndex::RTree::RTree* pTree, long id, unsigned long level) : Node(pTree, id, level, pTree->m_indexCapacity)
#else
Index::Index(RTree* pTree, long id, unsigned long level) : Node(pTree, id, level, pTree->m_indexCapacity)
#endif//_MSC_VER
{
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/spatialindex/rtree/Leaf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ Leaf::~Leaf()
{
}

#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Leaf::Leaf(SpatialIndex::RTree::RTree* pTree, long id): Node(pTree, id, 0, pTree->m_leafCapacity)
#else
Leaf::Leaf(RTree* pTree, long id): Node(pTree, id, 0, pTree->m_leafCapacity)
#endif//_MSC_VER
{
}

Expand Down
7 changes: 6 additions & 1 deletion src/core/spatialindex/rtree/Node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ Node::Node() :
{
}

Node::Node(RTree* pTree, long id, unsigned long level, unsigned long capacity) :
#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Node::Node(SpatialIndex::RTree::RTree* pTree, long id, unsigned long level, unsigned long capacity) :
#else
Node::Node(RTree* pTree, long id, unsigned long level, unsigned long capacity) :
#endif//_MSC_VER
m_pTree(pTree),
m_level(level),
m_identifier(id),
Expand Down
7 changes: 7 additions & 0 deletions src/core/spatialindex/storagemanager/DiskStorageManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

#ifdef WIN32
#include <io.h>
#ifdef _MSC_VER
#include <basetsd.h>
#endif//_MSC_VER
#define fsync(fd) _commit(fd)
#endif

Expand All @@ -39,6 +42,10 @@ using namespace SpatialIndex::StorageManager;
using std::map;
using std::vector;

#ifdef _MSC_VER
typedef SSIZE_T ssize_t;
#endif//_MSC_VER

SpatialIndex::IStorageManager* SpatialIndex::StorageManager::returnDiskStorageManager(Tools::PropertySet& ps)
{
IStorageManager* sm = new DiskStorageManager(ps);
Expand Down
Loading

0 comments on commit c7dba65

Please sign in to comment.