THRIFT-2221: detect C++11 and use std namespace for memory operations (smart_ptr)
Client: C++

This closes #1328
diff --git a/build/appveyor/MSVC-appveyor-build.bat b/build/appveyor/MSVC-appveyor-build.bat
index 054a8b4..a4b92a2 100644
--- a/build/appveyor/MSVC-appveyor-build.bat
+++ b/build/appveyor/MSVC-appveyor-build.bat
@@ -24,10 +24,12 @@
 @ECHO ON
   cmake "%SRCDIR%" ^
     -G"%GENERATOR%" ^
+	-DBISON_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe ^
     -DBOOST_ROOT="%BOOST_ROOT%" ^
     -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" ^
     -DCMAKE_BUILD_TYPE="%CONFIGURATION%" ^
     -DCMAKE_INSTALL_PREFIX="%INSTDIR%" ^
+	-DFLEX_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_flex.exe ^
     -DINTTYPES_ROOT="%WIN3P%\msinttypes" ^
     -DLIBEVENT_ROOT="%WIN3P%\libevent-%LIBEVENT_VERSION%-stable" ^
     -DOPENSSL_ROOT_DIR="%OPENSSL_ROOT%" ^
diff --git a/build/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake
index 365c0a4..2899937 100644
--- a/build/cmake/DefineCMakeDefaults.cmake
+++ b/build/cmake/DefineCMakeDefaults.cmake
@@ -70,11 +70,17 @@
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 
 #
-# C++ Language Level Defaults
+# C++ Language Level Defaults - this depends on the compiler capabilities
 #
 if (NOT DEFINED CMAKE_CXX_STANDARD)
-  set(CMAKE_CXX_STANDARD 11) # C++11
-  message(STATUS "Setting C++11 as the default language level.")
+  if (MSVC AND MSVC_VERSION LESS 1800)
+    # MSVC 2012 and earlier don't support template aliases so you have to use C++98
+    set(CMAKE_CXX_STANDARD 98) 
+    message(STATUS "Setting C++98 as the default language level (for an older MSVC compiler).")
+  else()
+    set(CMAKE_CXX_STANDARD 11) # C++11
+    message(STATUS "Setting C++11 as the default language level.")
+  endif()
   message(STATUS "To specify a different C++ language level, set CMAKE_CXX_STANDARD")
 endif()
 
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
index 63981e9..f1ea7bb 100644
--- a/build/cmake/DefineOptions.cmake
+++ b/build/cmake/DefineOptions.cmake
@@ -40,6 +40,16 @@
 # and enables the library if all are found. This means the default is to build as
 # much as possible but leaving out libraries if their dependencies are not met.
 
+option(WITH_BOOST_FUNCTIONAL "Use boost/tr1/functional.hpp even under C++11 or later" OFF)
+if (WITH_BOOST_FUNCTIONAL)
+    add_definitions(-DFORCE_BOOST_FUNCTIONAL)
+endif()
+
+option(WITH_BOOST_SMART_PTR "Use boost/smart_ptr.hpp even under C++11 or later" OFF)
+if (WITH_BOOST_SMART_PTR)
+    add_definitions(-DFORCE_BOOST_SMART_PTR)
+endif()
+
 option(WITH_BOOST_STATIC "Build with Boost static link library" OFF)
 set(Boost_USE_STATIC_LIBS ${WITH_BOOST_STATIC})
 if (NOT WITH_BOOST_STATIC)
@@ -197,6 +207,8 @@
 message(STATUS "  Build static libraries:                     ${WITH_STATIC_LIB}")
 message(STATUS "  Build with Boost static link library:       ${WITH_BOOST_STATIC}")
 message(STATUS "  Build with Boost thread support:            ${WITH_BOOSTTHREADS}")
+message(STATUS "  Build with boost/tr1/functional (forced)    ${WITH_BOOST_FUNCTIONAL}")
+message(STATUS "  Build with boost/smart_ptr (forced)         ${WITH_BOOST_SMART_PTR}")
 message(STATUS "  Build with C++ std::thread support:         ${WITH_STDTHREADS}")
 message(STATUS "  Build with libevent support:                ${WITH_LIBEVENT}")
 message(STATUS "  Build with OpenSSL support:                 ${WITH_OPENSSL}")
diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
index d5d27e2..f443489 100644
--- a/build/cmake/DefinePlatformSpecifc.cmake
+++ b/build/cmake/DefinePlatformSpecifc.cmake
@@ -109,7 +109,10 @@
   string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [with compiler-specific extensions]")
 else()
   if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -Wno-long-long -Wno-c++11-long-long")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -Wno-long-long")
+  endif()
+  if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-long-long")
   endif()
 endif()
 
@@ -117,8 +120,12 @@
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
 endif()
 
-# If gcc older than 4.8 is detected and plugin support was requested, fail fast
-if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8" AND WITH_PLUGIN)
-  message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler")
+# Building WITH_PLUGIN requires boost memory operations, for now, and gcc >= 4.8
+if (WITH_PLUGIN)
+  if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
+    message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler")
+  endif()
+  message(STATUS "Forcing use of boost::smart_ptr to build WITH_PLUGIN")
+  add_definitions("-DFORCE_BOOST_SMART_PTR=1")
 endif()
 
diff --git a/build/cmake/NewPlatformDebug.cmake b/build/cmake/NewPlatformDebug.cmake
index 76cac15..aa4d302 100644
--- a/build/cmake/NewPlatformDebug.cmake
+++ b/build/cmake/NewPlatformDebug.cmake
@@ -36,6 +36,7 @@
   SHOWFLAG("CYGWIN")
   SHOWFLAG("MINGW")
   SHOWFLAG("MSVC")
+  SHOWFLAG("MSVC_VERSION")
   SHOWFLAG("MSYS")
   SHOWFLAG("UNIX")
   SHOWFLAG("WATCOM")