Skip to content

Commit

Permalink
Fixes for code & tests under MSVC 2012. Refs #6527
Browse files Browse the repository at this point in the history
Thisgs to note:
 * C2450 warnings have been suppressed when including Poco headers
   that inherit from std::stream
 * Boost date_time no longer accepts just a date for an ISO date/time
   string
  • Loading branch information
martyngigg committed Feb 18, 2013
1 parent 02e2b4a commit 138d4a5
Show file tree
Hide file tree
Showing 32 changed files with 180 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/Build/CMake/FindCxxTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname)
add_custom_command(
OUTPUT ${_cxxtest_real_outfname}
DEPENDS ${PATH_FILES}
COMMAND python ${CXXTEST_TESTGEN_EXECUTABLE} --root
COMMAND ${PYTHON_EXECUTABLE} ${CXXTEST_TESTGEN_EXECUTABLE} --root
--xunit-printer --world ${_cxxtest_testname} -o ${_cxxtest_real_outfname}
)
set_source_files_properties(${_cxxtest_real_outfname} PROPERTIES GENERATED true)
Expand All @@ -122,7 +122,7 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname)
add_custom_command(
OUTPUT ${_cxxtest_cpp}
DEPENDS ${_cxxtest_h}
COMMAND python ${CXXTEST_TESTGEN_EXECUTABLE} --part
COMMAND ${PYTHON_EXECUTABLE} ${CXXTEST_TESTGEN_EXECUTABLE} --part
--world ${_cxxtest_testname} -o ${_cxxtest_cpp} ${_cxxtest_h}
)

Expand Down
38 changes: 34 additions & 4 deletions Code/Mantid/Build/CMake/WindowsNSIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,48 @@
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/bin/${WINDOWS_DEPLOYMENT_TYPE}/MantidAPI.lib" DESTINATION UserAlgorithms)
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/bin/${WINDOWS_DEPLOYMENT_TYPE}/MantidDataObjects.lib" DESTINATION UserAlgorithms)
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/bin/${WINDOWS_DEPLOYMENT_TYPE}/MantidCurveFitting.lib" DESTINATION UserAlgorithms)
install ( FILES ${CMAKE_LIBRARY_PATH}/PocoFoundation.lib ${CMAKE_LIBRARY_PATH}/PocoXML.lib ${CMAKE_LIBRARY_PATH}/boost_date_time-vc100-mt-1_43.lib DESTINATION UserAlgorithms)
# Poco libs for UserAlgorithms. Boost name depends on compiler version
install ( FILES ${CMAKE_LIBRARY_PATH}/PocoFoundation.lib ${CMAKE_LIBRARY_PATH}/PocoXML.lib DESTINATION UserAlgorithms)

# Copy MSVC runtime libraries
install (FILES ${CMAKE_LIBRARY_PATH}/CRT/msvcp100.dll ${CMAKE_LIBRARY_PATH}/CRT/msvcr100.dll ${CMAKE_LIBRARY_PATH}/CRT/vcomp100.dll DESTINATION bin)
if ( MSVC_VERSION EQUAL 1700 )
set ( RUNTIME_VER 110 )
# Boost library is a different version
install ( FILES ${CMAKE_LIBRARY_PATH}/boost_date_time-vc110-mt-1_52.lib DESTINATION UserAlgorithms )
else() # Assume 100 like we always did
set ( RUNTIME_VER 100 )
# Boost library is a different version
install ( FILES ${CMAKE_LIBRARY_PATH}/boost_date_time-vc100-mt-1_43.lib DESTINATION UserAlgorithms )
endif ()

file ( TO_CMAKE_PATH $ENV{VS${RUNTIME_VER}COMNTOOLS}/../../VC/redist VC_REDIST )
if ( CMAKE_CL_64 )
set ( VC_REDIST ${VC_REDIST}/x64 )
else()
set ( VC_REDIST ${VC_REDIST}/x86 )
endif()
# Runtime libraries
set ( RUNTIME_DLLS msvcp${RUNTIME_VER}.dll msvcr${RUNTIME_VER}.dll )
set ( REDIST_SUBDIR Microsoft.VC${RUNTIME_VER}.CRT )
foreach( DLL ${RUNTIME_DLLS} )
install ( FILES ${VC_REDIST}/${REDIST_SUBDIR}/${DLL} DESTINATION bin )
endforeach()

# openmp library(s)
set ( OPENMP_DLLS vcomp${RUNTIME_VER}.dll )
set ( REDIST_SUBDIR Microsoft.VC${RUNTIME_VER}.OpenMP )
foreach( DLL ${OPENMP_DLLS} )
install ( FILES ${VC_REDIST}/${REDIST_SUBDIR}/${DLL} DESTINATION bin )
endforeach()

# Copy Intel fortran libraries from numpy to general bin directory. Both numpy & scipy are compiled with intel compiler as it is the only way to get 64-bit libs at the moment.
# This means scipy requires the intel libraries that are stuck in numpy/core.
file ( GLOB INTEL_DLLS "${CMAKE_LIBRARY_PATH}/Python27/Lib/site-packages/numpy/core/*.dll" )
install ( FILES ${INTEL_DLLS} DESTINATION ${INBUNDLE}bin )

# Copy third party dlls excluding selected Qt ones and debug ones
install ( DIRECTORY ${CMAKE_LIBRARY_PATH}/ DESTINATION bin FILES_MATCHING PATTERN "*.dll"
REGEX "${CMAKE_LIBRARY_PATH}/CRT/*" EXCLUDE
install ( DIRECTORY ${CMAKE_LIBRARY_PATH}/ DESTINATION bin FILES_MATCHING PATTERN "*.dll"
REGEX "${CMAKE_LIBRARY_PATH}/CRT/*" EXCLUDE
REGEX "${CMAKE_LIBRARY_PATH}/Python27/*" EXCLUDE
REGEX "${CMAKE_LIBRARY_PATH}/qt_plugins/*" EXCLUDE
REGEX "(QtDesigner4.dll)|(QtDesignerComponents4.dll)|(QtScript4.dll)|(-gd-)|(d4.dll)|(_d.dll)"
Expand Down
13 changes: 10 additions & 3 deletions Code/Mantid/Build/CMake/WindowsSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif()
##########################################################################
# Additional compiler flags
##########################################################################
# /MP - Multiprocessor compilation within a project
# /MP - Compile .cpp files in parallel
# /w34296 - Treat warning C4396, about comparison on unsigned and zero,
# as a level 3 warning
# /w34389 - Treat warning C4389, about equality comparison on unsigned
Expand All @@ -43,8 +43,15 @@ endif ()
###########################################################################
## Set the variables that FindPythonLibs would set
set ( PYTHON_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}/Python27" "${CMAKE_INCLUDE_PATH}/Python27/Include" )
set ( PYTHON_LIBRARIES "${CMAKE_LIBRARY_PATH}/Python27/python27.lib" )
set ( PYTHON_DEBUG_LIBRARY "${CMAKE_LIBRARY_PATH}/Python27/python27_d.lib" )
# Libraries can be in one of two places. This allows it still to build with the old locations
if ( EXISTS "${CMAKE_LIBRARY_PATH}/Python27/libs" )
set ( PYTHON_LIBRARIES "${CMAKE_LIBRARY_PATH}/Python27/libs/python27.lib" )
set ( PYTHON_DEBUG_LIBRARY "${CMAKE_LIBRARY_PATH}/Python27/libs/python27_d.lib" )
else()
set ( PYTHON_LIBRARIES "${CMAKE_LIBRARY_PATH}/Python27/python27.lib" )
set ( PYTHON_DEBUG_LIBRARY "${CMAKE_LIBRARY_PATH}/Python27/python27_d.lib" )
endif()

set ( PYTHON_DEBUG_LIBRARIES ${PYTHON_DEBUG_LIBRARY} )
## Add debug library into libraries variable
set ( PYTHON_LIBRARIES optimized ${PYTHON_LIBRARIES} debug ${PYTHON_DEBUG_LIBRARIES} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <Poco/DOM/Text.h>
#include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/XML/XMLWriter.h>
#include <sstream>
#include <vector>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/BoxController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <Poco/DOM/DOMWriter.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/Text.h>
#include <Poco/XML/XMLWriter.h>

#include <sstream>

using namespace Mantid::Kernel;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ namespace API
if (validTo.length() > 0)
to.setFromISO8601(validTo);
else
to.setFromISO8601("2100-01-01");
to.setFromISO8601("2100-01-01T00:00:00");

if ( from <= d && d <= to )
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ namespace Mantid
if (!log)
throw std::runtime_error("EventWorkspace::getFirstPulseTime: No TimeSeriesProperty called 'proton_charge' found in the workspace.");
DateAndTime startDate;
DateAndTime reference("1991-01-01");
DateAndTime reference("1991-01-01T00:00:00");

int i=0;
startDate = log->nthTime(i);
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/ExperimentInfoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ class ExperimentInfoTest : public CxxTest::TestSuite
if (validTo.length() > 0)
ft.to.setFromISO8601(validTo);
else
ft.to.setFromISO8601("2100-01-01");
ft.to.setFromISO8601("2100-01-01T00:00:00");

idfFiles.insert( std::pair<std::string,fromToEntry>(l_filenamePart.substr(0,found),
ft) );
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Algorithms/src/FilterByLogValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void FilterByLogValue::exec()
const bool PulseFilter = getProperty("PulseFilter");

// Find the start and stop times of the run, but handle it if they are not found.
DateAndTime run_start(0), run_stop("2100-01-01");
DateAndTime run_start(0), run_stop("2100-01-01T00:00:00");
double handle_edge_values = false;
try
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Algorithms/test/AverageLogDataTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AverageLogDataTest : public CxxTest::TestSuite
{
inputWS="AverageLogDataTestWS";
Mantid::DataObjects::Workspace2D_sptr w=WorkspaceCreationHelper::Create2DWorkspace(1,1);
Mantid::Kernel::DateAndTime run_start("2010-01-01");
Mantid::Kernel::DateAndTime run_start("2010-01-01T00:00:00");
Mantid::Kernel::TimeSeriesProperty<double> *pc,*p1;
pc=new Mantid::Kernel::TimeSeriesProperty<double>("proton_charge");
pc->setUnits("picoCoulomb");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class FindDetectorsOutsideLimitsTest : public CxxTest::TestSuite
EventWorkspace_sptr work_in = WorkspaceCreationHelper::CreateEventWorkspace(50, 100, 100, 0.0, 1.0, 2, 1);
Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(10);
work_in->setInstrument(inst);
DateAndTime run_start("2010-01-01");
DateAndTime run_start("2010-01-01T00:00:00");
// Add ten more at #10 so that it fails
for (int i=0; i<10; i++)
work_in->getEventList(10).addEventQuickly( TofEvent((i+0.5), run_start+double(i)) );
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/AnvredCorrectionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AnvredCorrectionTest : public CxxTest::TestSuite
// Populate the instrument parameters in this workspace - this works around a bug
retVal->populateInstrumentParameters();

DateAndTime run_start("2010-01-01");
DateAndTime run_start("2010-01-01T00:00:00");

for (int pix = 0; pix < numPixels; pix++)
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/CentroidPeaksTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CentroidPeaksTest : public CxxTest::TestSuite
// Populate the instrument parameters in this workspace - this works around a bug
retVal->populateInstrumentParameters();

DateAndTime run_start("2010-01-01");
DateAndTime run_start("2010-01-01T00:00:00");

for (int pix = 0; pix < numPixels; pix++)
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/NormaliseVanadiumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class NormaliseVanadiumTest : public CxxTest::TestSuite
// Populate the instrument parameters in this workspace - this works around a bug
retVal->populateInstrumentParameters();

DateAndTime run_start("2010-01-01");
DateAndTime run_start("2010-01-01T00:00:00");

for (int pix = 0; pix < numPixels; pix++)
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/PeakIntegrationTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PeakIntegrationTest : public CxxTest::TestSuite
// Populate the instrument parameters in this workspace - this works around a bug
retVal->populateInstrumentParameters();

DateAndTime run_start("2010-01-01");
DateAndTime run_start("2010-01-01T00:00:00");

for (int pix = 0; pix < numPixels; pix++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ The x and y extents in the par file are radians(step)*distance and 0.01, and are
#include "Poco/DOM/Text.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/DOM/DOMWriter.h"
#include "Poco/XML/XMLWriter.h"

#ifdef _MSC_VER
// Disable a flood of warnings from Poco about inheriting from std::basic_istream
// See http://connect.microsoft.com/VisualStudio/feedback/details/733720/inheriting-from-std-fstream-produces-c4250-warning
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif

#include <Poco/XML/XMLWriter.h>

#ifdef _MSC_VER
#pragma warning( pop )
#endif

#include <fstream>

using namespace Mantid::Kernel;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ BankPulseTimes * LoadEventNexus::runLoadNexusLogs(const std::string &nexusfilena
// Use the first pulse as the run_start time.
if (!temp.empty())
{
if (temp[0] < Kernel::DateAndTime("1991-01-01"))
if (temp[0] < Kernel::DateAndTime("1991-01-01T00:00:00"))
alg->getLogger().warning() << "Found entries in the proton_charge sample log with invalid pulse time!\n";

Kernel::DateAndTime run_start = localWorkspace->getFirstPulseTime();
Expand Down
13 changes: 12 additions & 1 deletion Code/Mantid/Framework/DataHandling/src/SaveDetectorsGrouping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ This algorithm saves a GroupingWorkspace to an XML file.
#include "Poco/DOM/Text.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/DOM/DOMWriter.h"
#include "Poco/XML/XMLWriter.h"
#ifdef _MSC_VER
// Disable a flood of warnings from Poco about inheriting from std::basic_istream
// See http://connect.microsoft.com/VisualStudio/feedback/details/733720/inheriting-from-std-fstream-produces-c4250-warning
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif

#include <Poco/XML/XMLWriter.h>

#ifdef _MSC_VER
#pragma warning( pop )
#endif

using namespace Mantid::Kernel;
using namespace Mantid::API;
Expand Down
13 changes: 12 additions & 1 deletion Code/Mantid/Framework/DataHandling/src/SaveMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ This algorithm saves a SpecialWorkspace2D/MaskWorkspace to an XML file.
#include "Poco/DOM/Text.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/DOM/DOMWriter.h"
#include "Poco/XML/XMLWriter.h"
#ifdef _MSC_VER
// Disable a flood of warnings from Poco about inheriting from std::basic_istream
// See http://connect.microsoft.com/VisualStudio/feedback/details/733720/inheriting-from-std-fstream-produces-c4250-warning
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif

#include <Poco/XML/XMLWriter.h>

#ifdef _MSC_VER
#pragma warning( pop )
#endif

using namespace Mantid::Kernel;
using namespace Mantid::API;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@
#include <typeinfo>
#include <vector>
#include <Poco/SAX/Attributes.h>
#ifdef _MSC_VER
// Disable a flood of warnings from Poco about inheriting from std::basic_istream
// See http://connect.microsoft.com/VisualStudio/feedback/details/733720/inheriting-from-std-fstream-produces-c4250-warning
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif

#include <Poco/XML/XMLWriter.h>

#ifdef _MSC_VER
#pragma warning( pop )
#endif

namespace Mantid
{
namespace Kernel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ namespace Mantid
{
const ComponentID id = comp->getComponentID();
pmap_cit it_found = m_map.find(id);
if( it_found->first && it_found != m_map.end() )
if( it_found != m_map.end() && it_found->first )
{
pmap_cit itr = m_map.lower_bound(id);
pmap_cit itr_end = m_map.upper_bound(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <Poco/DOM/Text.h>
#include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/XML/XMLWriter.h>
#include <sstream>
namespace Mantid
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <Poco/DOM/Text.h>
#include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/XML/XMLWriter.h>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
#include "MantidGeometry/Objects/Object.h"
#include "MantidGeometry/Rendering/GeometryHandler.h"

#include <Poco/FileStream.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/Text.h>
#include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/DOMWriter.h>

#ifdef _MSC_VER
// Disable a flood of warnings from Poco about inheriting from std::basic_istream
// See http://connect.microsoft.com/VisualStudio/feedback/details/733720/inheriting-from-std-fstream-produces-c4250-warning
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif
#include <Poco/FileStream.h>
#include <Poco/XML/XMLWriter.h>
#ifdef _MSC_VER
#pragma warning( pop )
#endif

#include <Poco/File.h>
#include <Poco/Path.h>

Expand Down
1 change: 0 additions & 1 deletion Code/Mantid/Framework/Geometry/test/ComponentParserTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <iomanip>
#include <iostream>
#include <Poco/SAX/SAXParser.h>
#include <Poco/XML/XMLWriter.h>
#include <sstream>
#include "MantidKernel/CPUTimer.h"
#include "MantidKernel/Strings.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
// Includes
//--------------------------------------------
#include "MantidKernel/DllConfig.h"

#include <Poco/Logger.h>
#ifdef _MSC_VER
// Disable a flood of warnings about inheriting from std streams
// See http://connect.microsoft.com/VisualStudio/feedback/details/733720/inheriting-from-std-fstream-produces-c4250-warning
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif

#include <Poco/LogStream.h>
#include <Poco/UnbufferedStreamBuf.h>

#include <istream>
#include <Poco/Thread.h>

Expand Down Expand Up @@ -156,4 +165,9 @@ class MANTID_KERNEL_DLL ThreadSafeLogStream : public ThreadSafeLogIOS, public st

}

#ifdef _MSC_VER
#pragma warning( pop )
#endif


#endif //MANTID_KERNEL_THREADSAFELOGSTREAM
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Kernel/src/ConfigService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <Poco/Environment.h>
#include <Poco/Process.h>
#include <Poco/String.h>
#ifdef _WIN32
#pragma warning( disable: 4250 )
#endif
#include <Poco/PipeStream.h>
#include <Poco/StreamCopier.h>

Expand Down

0 comments on commit 138d4a5

Please sign in to comment.