From 483ac66518714df6897172948622719f25d527e5 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Mon, 13 Jan 2014 11:48:16 -0800 Subject: [PATCH] more windows build tweaks, warnings and linking --- CMakeLists.txt | 4 +++- interface/CMakeLists.txt | 8 ++++++-- libraries/metavoxels/src/Bitstream.h | 10 +++++++++- libraries/shared/src/Assignment.cpp | 11 +++++++++++ libraries/shared/src/NodeList.cpp | 13 +++++++++++++ 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 101e3e7603..839150541b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,9 @@ cmake_minimum_required(VERSION 2.8) project(hifi) IF (WIN32) - add_definitions( -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS ) + add_definitions( -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -DTEST) + #MESSAGE(${CMAKE_PREFIX_PATH}) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A") ENDIF(WIN32) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH}) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 6a5bce0497..7bc1c4d32d 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -34,9 +34,13 @@ if (UNIX AND NOT APPLE) endif (UNIX AND NOT APPLE) if (WIN32) + MESSAGE(${CMAKE_PREFIX_PATH}) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A") + MESSAGE(${CMAKE_PREFIX_PATH}) + add_definitions( -D_USE_MATH_DEFINES -DWINDOWS_LEAN_AND_MEAN ) # apparently needed to get M_PI and other defines from cmath/math.h - #set(GLUT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glut) + set(GLUT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glut) #set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0\n#include \n#include \n#include \n#include ") # this bit of #define GLdouble GLdouble is to fix up a mismatch between windows and the Qt versions of open GL. @@ -233,7 +237,7 @@ if (WIN32) target_link_libraries( ${TARGET_NAME} #${CMAKE_CURRENT_SOURCE_DIR}/external/glut/Release/glew32.lib - #${CMAKE_CURRENT_SOURCE_DIR}/external/glut/Release/freeglut.lib + ${CMAKE_CURRENT_SOURCE_DIR}/external/glut/Release/freeglut.lib #${CMAKE_CURRENT_SOURCE_DIR}/external/glut/Release/pthread_lib.lib wsock32.lib ) diff --git a/libraries/metavoxels/src/Bitstream.h b/libraries/metavoxels/src/Bitstream.h index 3e9174c1ba..09c14d63e6 100644 --- a/libraries/metavoxels/src/Bitstream.h +++ b/libraries/metavoxels/src/Bitstream.h @@ -318,11 +318,19 @@ public: /// Declares the metatype and the streaming operators. The last lines /// ensure that the generated file will be included in the link phase. #define STRINGIFY(x) #x +#ifdef _WIN32 +#define DECLARE_STREAMABLE_METATYPE(X) Q_DECLARE_METATYPE(X) \ + Bitstream& operator<<(Bitstream& out, const X& obj); \ + Bitstream& operator>>(Bitstream& in, X& obj); \ + static const int* _TypePtr##X = &X::Type; +#else +#define STRINGIFY(x) #x #define DECLARE_STREAMABLE_METATYPE(X) Q_DECLARE_METATYPE(X) \ Bitstream& operator<<(Bitstream& out, const X& obj); \ Bitstream& operator>>(Bitstream& in, X& obj); \ static const int* _TypePtr##X = &X::Type; \ - _Pragma(STRINGIFY(unused(_TypePtr##X))) + _Pragma(STRINGIFY(unused(_TypePtr##X))) +#endif /// Registers a streamable type and its streamer. template int registerStreamableMetaType() { diff --git a/libraries/shared/src/Assignment.cpp b/libraries/shared/src/Assignment.cpp index a0168e4bf0..ef57f838cb 100644 --- a/libraries/shared/src/Assignment.cpp +++ b/libraries/shared/src/Assignment.cpp @@ -36,6 +36,12 @@ Assignment::Type Assignment::typeForNodeType(NODE_TYPE nodeType) { } } +#ifdef WIN32 +//warning C4351: new behavior: elements of array 'Assignment::_payload' will be default initialized +// We're disabling this warning because the new behavior which is to initialize the array with 0 is acceptable to us. +#pragma warning(disable:4351) +#endif + Assignment::Assignment() : _uuid(), _command(Assignment::RequestCommand), @@ -106,6 +112,11 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) : } } +#ifdef WIN32 +#pragma warning(default:4351) +#endif + + Assignment::Assignment(const Assignment& otherAssignment) { _uuid = otherAssignment._uuid; diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 6c068524b4..8d7dd5b5af 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -51,6 +51,13 @@ NodeList* NodeList::getInstance() { return _sharedInstance; } +#ifdef WIN32 +//warning C4351: new behavior: elements of array 'NodeList::_nodeBuckets' will be default initialized +// We're disabling this warning because the new behavior which is to initialize the array with 0 is acceptable to us. +#pragma warning(disable:4351) +#endif + + NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) : _domainHostname(DEFAULT_DOMAIN_HOSTNAME), _domainSockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)), @@ -70,6 +77,12 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) : qDebug() << "NodeList socket is listening on" << _nodeSocket.localPort() << "\n"; } +#ifdef WIN32 +//warning C4351: new behavior: elements of array 'NodeList::_nodeBuckets' will be default initialized +#pragma warning(default:4351) +#endif + + NodeList::~NodeList() { delete _nodeTypesOfInterest;