PARQUET-1313: [C++] Fix gtest build failure on Windows

Also add an option to enable clcache if found.

Author: Antoine Pitrou <antoine@python.org>

Closes #468 from pitrou/PARQUET-1313-msvc-gtest-warnings and squashes the following commits:

7aefdcf [Antoine Pitrou] Enable a VS2017 build on AppVeyor
1c3a78e [Antoine Pitrou] PARQUET-1313: [C++] Fix gtest build failure on Windows
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e100a3..52f63d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -164,6 +164,9 @@
     option(PARQUET_USE_STATIC_CRT
       "Build Parquet with statically linked CRT"
       OFF)
+    option(PARQUET_USE_CLCACHE
+      "Use clcache if available"
+      ON)
   endif()
 
   option(PARQUET_VERBOSE_THIRDPARTY_BUILD
@@ -172,6 +175,15 @@
 
 endif()
 
+if (MSVC AND PARQUET_USE_CLCACHE AND
+     (("${CMAKE_GENERATOR}" STREQUAL "NMake Makefiles") OR
+      ("${CMAKE_GENERATOR}" STREQUAL "Ninja")))
+  find_program(CLCACHE_FOUND clcache)
+  if(CLCACHE_FOUND)
+    set(CMAKE_CXX_COMPILER ${CLCACHE_FOUND})
+  endif(CLCACHE_FOUND)
+endif()
+
 include(BuildUtils)
 
 if (PARQUET_BUILD_TESTS OR PARQUET_BUILD_EXECUTABLES OR PARQUET_BUILD_BENCHMARKS)
diff --git a/appveyor.yml b/appveyor.yml
index 7e39320..5cc8354 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -18,6 +18,9 @@
 # Operating system (build VM template)
 os: Visual Studio 2015
 
+matrix:
+  fast_finish: true
+
 environment:
   matrix:
     - GENERATOR: NMake Makefiles
@@ -28,10 +31,12 @@
       PYTHON: "3.5"
       ARCH: "64"
       CONFIGURATION: "Debug"
-    - GENERATOR: Visual Studio 14 2015 Win64
+    - GENERATOR: Visual Studio 15 2017 Win64
       PYTHON: "3.5"
       ARCH: "64"
       CONFIGURATION: "Release"
+      APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+      BOOST_ROOT: C:\Libraries\boost_1_64_0
     - GENERATOR: Visual Studio 14 2015 Win64
       PYTHON: "3.5"
       ARCH: "64"
@@ -46,14 +51,18 @@
       PYTHON: "3.5"
       ARCH: "64"
       CONFIGURATION: "Toolchain"
+
   MSVC_DEFAULT_OPTIONS: ON
   BOOST_ROOT: C:\Libraries\boost_1_63_0
   BOOST_LIBRARYDIR: C:\Libraries\boost_1_63_0\lib64-msvc-14.0
+  USE_CLCACHE: false
 
 init:
   - set MINICONDA=C:\Miniconda35-x64
   - set PATH=%MINICONDA%;%MINICONDA%/Scripts;%MINICONDA%/Library/bin;%PATH%
-  - if "%GENERATOR%"=="NMake Makefiles" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
 
 build_script:
   - call ci\msvc-build.bat
+
+# Disable test discovery
+test: off
diff --git a/ci/msvc-build.bat b/ci/msvc-build.bat
index 6cca539..0136819 100644
--- a/ci/msvc-build.bat
+++ b/ci/msvc-build.bat
@@ -32,6 +32,17 @@
   set PARQUET_CXXFLAGS="%PARQUET_CXXFLAGS% /WX"
 )
 
+if "%GENERATOR%"=="NMake Makefiles" set need_vcvarsall=1
+
+if defined need_vcvarsall (
+    @rem Select desired compiler version
+    if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" (
+        call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
+    ) else (
+        call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
+    )
+)
+
 if "%CONFIGURATION%" == "Toolchain" (
   conda install -y boost-cpp=1.63 thrift-cpp=0.11.0 ^
       brotli=0.6.0 zlib=1.2.11 snappy=1.1.6 lz4-c=1.7.5 zstd=1.2.0 ^
@@ -47,7 +58,6 @@
       .. || exit /B
 
   cmake --build . --config Release || exit /B
-  ctest -VV || exit /B
 )
 
 if NOT "%CONFIGURATION%" == "Toolchain" (
@@ -59,8 +69,9 @@
         .. || exit /B
 
   cmake --build . --config %CONFIGURATION% || exit /B
+)
 
-  if "%CONFIGURATION%" == "Release" (
+if NOT "%CONFIGURATION%" == "Debug" (
+    @rem Tests are too slow and/or hang in debug mode
     ctest -VV || exit /B
-  )
 )
diff --git a/cmake_modules/ThirdpartyToolchain.cmake b/cmake_modules/ThirdpartyToolchain.cmake
index c23fea9..b2de4d2 100644
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
@@ -287,6 +287,10 @@
   if("$ENV{GTEST_HOME}" STREQUAL "")
     if(APPLE)
       set(GTEST_CMAKE_CXX_FLAGS "${EP_CXX_FLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes")
+    elseif(MSVC)
+      # Workaround https://github.com/google/googletest/issues/1111 until
+      # a new gtest version is released
+      set(GTEST_CMAKE_CXX_FLAGS "${EP_CXX_FLAGS} -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING")
     else()
       set(GTEST_CMAKE_CXX_FLAGS "${EP_CXX_FLAGS}")
     endif()