From f806576cf20b3cebb60fe3bb09b29dfc6c4e4be2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 31 May 2013 23:48:06 +0600 Subject: [PATCH] Collections port fix for MSVC 2008 Apparently, TR1 symbols are defined in different namespace comparing to MSVC 2010, which lead to compilation error when using MSVC 2008. Change-Id: I4fa3ceae4b4e2c6e7a46b1fb5b498640e7b18b74 --- CMakeLists.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75186760d..df8d1a788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -530,9 +530,23 @@ ELSE (DISABLE_TR1) # Use the std namespace for the hash<> and related templates. This may vary by # system. IF (MSVC) - # This is known to work with Visual Studio 2010 Express. - ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std {\"") - ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}\"") + IF (MSVC90) + # Special case for Visual Studio 2008. + # Newer versions have got tr1 symbols in another namespace, + # and this is being handled in Else branch of this condition. + # Probably Visual studio 2003 and 2005 also shall be handled here, + # but don't have by hand to verify and most likely they're not + # used by Ceres users anyway. + ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"") + ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}}\"") + ELSE (MSVC90) + # This is known to work with Visual Studio 2010 Express. + # Further, for as long Visual Studio 2012 didn't move tr1 to + # just another namespace, the same define will work for it as well. + # Hopefully all further versions will also keep working with this define. + ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std {\"") + ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}\"") + ENDIF(MSVC90) ELSE (MSVC) # This is known to work with recent versions of Linux and Mac OS X. ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"")